Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

token: make is_assign() contain .decl_assign #21805

Merged
merged 1 commit into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/tools/vdoc/highlight.v
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ fn color_highlight(code string, tb &ast.Table) string {
else {
if token.is_key(tok.lit) || token.is_decl(tok.kind) {
tok_typ = .keyword
} else if tok.kind == .decl_assign || tok.kind.is_assign() || tok.is_unary()
|| tok.kind.is_relational() || tok.kind.is_infix() || tok.kind.is_postfix() {
} else if tok.kind.is_assign() || tok.is_unary() || tok.kind.is_relational()
|| tok.kind.is_infix() || tok.kind.is_postfix() {
tok_typ = .operator
}
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/tools/vdoc/html.v
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,8 @@ fn html_highlight(code string, tb &ast.Table) string {
else {
if token.is_key(tok.lit) || token.is_decl(tok.kind) {
tok_typ = .keyword
} else if tok.kind == .decl_assign || tok.kind.is_assign() || tok.is_unary()
|| tok.kind.is_relational() || tok.kind.is_infix() || tok.kind.is_postfix() {
} else if tok.kind.is_assign() || tok.is_unary() || tok.kind.is_relational()
|| tok.kind.is_infix() || tok.kind.is_postfix() {
tok_typ = .operator
}
}
Expand Down
4 changes: 2 additions & 2 deletions vlib/v/parser/for.v
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn (mut p Parser) for_stmt() ast.Stmt {
}
p.close_scope()
return for_stmt
} else if p.peek_tok.kind in [.decl_assign, .assign, .semicolon]
} else if p.peek_tok.kind == .semicolon
|| (p.peek_tok.kind in [.inc, .dec] && p.peek_token(2).kind in [.semicolon, .comma])
|| p.peek_tok.kind.is_assign() || p.tok.kind == .semicolon
|| (p.peek_tok.kind == .comma && p.peek_token(2).kind != .key_mut
Expand All @@ -47,7 +47,7 @@ fn (mut p Parser) for_stmt() ast.Stmt {
mut has_inc := false
mut is_multi := p.peek_tok.kind == .comma && p.peek_token(2).kind != .key_mut
&& p.peek_token(3).kind != .key_in
if p.peek_tok.kind in [.assign, .decl_assign] || p.peek_tok.kind.is_assign() || is_multi {
if p.peek_tok.kind.is_assign() || is_multi {
init = p.assign_stmt()
has_init = true
} else if p.peek_tok.kind in [.inc, .dec] {
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/parser/parser.v
Original file line number Diff line number Diff line change
Expand Up @@ -2156,7 +2156,7 @@ fn (mut p Parser) parse_multi_expr(is_top_level bool) ast.Stmt {
return p.error('expecting `:=` (e.g. `mut x :=`)')
}
// TODO: remove translated
if p.tok.kind in [.assign, .decl_assign] || p.tok.kind.is_assign() {
if p.tok.kind.is_assign() {
return p.partial_assign_stmt(left)
} else if !p.pref.translated && !p.is_translated && !p.pref.is_fmt && !p.pref.is_vet
&& tok.kind !in [.key_if, .key_match, .key_lock, .key_rlock, .key_select] {
Expand Down
6 changes: 3 additions & 3 deletions vlib/v/token/token.v
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@ pub enum AtKind {
location
}

pub const assign_tokens = [Kind.assign, .plus_assign, .minus_assign, .mult_assign, .div_assign,
.xor_assign, .mod_assign, .or_assign, .and_assign, .right_shift_assign, .left_shift_assign,
.unsigned_right_shift_assign, .boolean_and_assign, .boolean_or_assign]
pub const assign_tokens = [Kind.assign, .decl_assign, .plus_assign, .minus_assign, .mult_assign,
.div_assign, .xor_assign, .mod_assign, .or_assign, .and_assign, .right_shift_assign,
.left_shift_assign, .unsigned_right_shift_assign, .boolean_and_assign, .boolean_or_assign]

pub const valid_at_tokens = ['@VROOT', '@VMODROOT', '@VEXEROOT', '@FN', '@METHOD', '@MOD', '@STRUCT',
'@VEXE', '@FILE', '@LINE', '@COLUMN', '@VHASH', '@VCURRENTHASH', '@VMOD_FILE', '@VMODHASH',
Expand Down
Loading