From bac6be227350d0db83b5ae00c361f1240fb81997 Mon Sep 17 00:00:00 2001 From: yuyi Date: Sun, 6 Dec 2020 23:48:23 +0800 Subject: [PATCH] token: minor clean up (#7163) --- vlib/v/token/token.v | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/vlib/v/token/token.v b/vlib/v/token/token.v index fae33c9e0b..319f1ecf9b 100644 --- a/vlib/v/token/token.v +++ b/vlib/v/token/token.v @@ -179,7 +179,7 @@ fn build_keys() map[string]Kind { // TODO remove once we have `enum Kind { name('name') if('if') ... }` fn build_token_str() []string { - mut s := []string{len: (nr_tokens)} + mut s := []string{len: nr_tokens} s[Kind.unknown] = 'unknown' s[Kind.eof] = 'eof' s[Kind.name] = 'name' @@ -295,8 +295,7 @@ const ( ) pub fn key_to_token(key string) Kind { - a := Kind(keywords[key]) - return a + return Kind(keywords[key]) } pub fn is_key(key string) bool { @@ -353,7 +352,7 @@ pub enum Precedence { } pub fn build_precedences() []Precedence { - mut p := []Precedence{len: int(Kind._end_), cap: int(Kind._end_)} + mut p := []Precedence{len: int(Kind._end_)} p[Kind.lsbr] = .index p[Kind.dot] = .call // `++` | `--` | `?`