mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
compiler: blank ident error fixes + other small cflag / parser fixes (#2418)
* merge master * fix blank ident & add cflag error * undo cflag changes * fix gen_js * undo gen_js changes * fix * fix
This commit is contained in:
parent
c18578af6f
commit
28b24eeef6
@ -93,7 +93,7 @@ fn (table mut Table) parse_cflag(cflag string, mod string) {
|
|||||||
if flag[0] == `-` {
|
if flag[0] == `-` {
|
||||||
for f in allowed_flags {
|
for f in allowed_flags {
|
||||||
i := 1+f.len
|
i := 1+f.len
|
||||||
if i < flag.len && f == flag.substr(1,i) {
|
if i <= flag.len && f == flag.substr(1,i) {
|
||||||
name = flag.left(i).trim_space()
|
name = flag.left(i).trim_space()
|
||||||
flag = flag.right(i).trim_space()
|
flag = flag.right(i).trim_space()
|
||||||
break
|
break
|
||||||
@ -137,6 +137,7 @@ fn (table mut Table) parse_cflag(cflag string, mod string) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: implement msvc specific c_options_before_target and c_options_after_target ...
|
//TODO: implement msvc specific c_options_before_target and c_options_after_target ...
|
||||||
|
@ -179,12 +179,14 @@ fn (p mut Parser) chash() {
|
|||||||
// println('chsh() file=$p.file hash="$hash"')
|
// println('chsh() file=$p.file hash="$hash"')
|
||||||
p.next()
|
p.next()
|
||||||
if hash.starts_with('flag ') {
|
if hash.starts_with('flag ') {
|
||||||
mut flag := hash.right(5)
|
p.first_pass() {
|
||||||
// expand `@VROOT` `@VMOD` to absolute path
|
mut flag := hash.right(5)
|
||||||
flag = flag.replace('@VROOT', p.vroot)
|
// expand `@VROOT` `@VMOD` to absolute path
|
||||||
flag = flag.replace('@VMOD', v_modules_path)
|
flag = flag.replace('@VROOT', p.vroot)
|
||||||
//p.log('adding flag "$flag"')
|
flag = flag.replace('@VMOD', v_modules_path)
|
||||||
p.table.parse_cflag(flag, p.mod)
|
//p.log('adding flag "$flag"')
|
||||||
|
p.table.parse_cflag(flag, p.mod)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if hash.starts_with('include') {
|
if hash.starts_with('include') {
|
||||||
|
@ -92,14 +92,23 @@ fn (p mut Parser) gen_blank_identifier_assign() {
|
|||||||
assign_error_tok_idx := p.token_idx
|
assign_error_tok_idx := p.token_idx
|
||||||
p.check_name()
|
p.check_name()
|
||||||
p.check_space(.assign)
|
p.check_space(.assign)
|
||||||
expr := p.lit
|
|
||||||
is_indexer := p.peek() == .lsbr
|
is_indexer := p.peek() == .lsbr
|
||||||
is_fn_call := p.peek() == .lpar || (p.peek() == .dot && p.tokens[p.token_idx+2].tok == .lpar)
|
mut expr := p.lit
|
||||||
if !is_indexer && !is_fn_call {
|
mut is_fn_call := p.peek() == .lpar
|
||||||
p.error_with_token_index('assigning `$expr` to `_` is redundant', assign_error_tok_idx)
|
if !is_fn_call {
|
||||||
|
mut i := p.token_idx+1
|
||||||
|
for (p.tokens[i].tok == .dot || p.tokens[i].tok == .name) &&
|
||||||
|
p.tokens[i].lit != '_' {
|
||||||
|
expr += if p.tokens[i].tok == .dot { '.' } else { p.tokens[i].lit }
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
is_fn_call = p.tokens[i].tok == .lpar
|
||||||
}
|
}
|
||||||
pos := p.cgen.add_placeholder()
|
pos := p.cgen.add_placeholder()
|
||||||
mut typ := p.bool_expression()
|
mut typ := p.bool_expression()
|
||||||
|
if !is_indexer && !is_fn_call {
|
||||||
|
p.error_with_token_index('assigning `$expr` to `_` is redundant', assign_error_tok_idx)
|
||||||
|
}
|
||||||
tmp := p.get_tmp()
|
tmp := p.get_tmp()
|
||||||
// handle or
|
// handle or
|
||||||
if p.tok == .key_orelse {
|
if p.tok == .key_orelse {
|
||||||
|
@ -38,13 +38,22 @@ fn (p mut Parser) gen_blank_identifier_assign() {
|
|||||||
assign_error_tok_idx := p.token_idx
|
assign_error_tok_idx := p.token_idx
|
||||||
p.check_name()
|
p.check_name()
|
||||||
p.check_space(.assign)
|
p.check_space(.assign)
|
||||||
expr := p.lit
|
|
||||||
is_indexer := p.peek() == .lsbr
|
is_indexer := p.peek() == .lsbr
|
||||||
is_fn_call := p.peek() == .lpar || (p.peek() == .dot && p.tokens[p.token_idx+2].tok == .lpar)
|
mut expr := p.lit
|
||||||
|
mut is_fn_call := p.peek() == .lpar
|
||||||
|
if !is_fn_call {
|
||||||
|
mut i := p.token_idx+1
|
||||||
|
for (p.tokens[i].tok == .dot || p.tokens[i].tok == .name) &&
|
||||||
|
p.tokens[i].lit != '_' {
|
||||||
|
expr += if p.tokens[i].tok == .dot { '.' } else { p.tokens[i].lit }
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
is_fn_call = p.tokens[i].tok == .lpar
|
||||||
|
}
|
||||||
|
p.bool_expression()
|
||||||
if !is_indexer && !is_fn_call {
|
if !is_indexer && !is_fn_call {
|
||||||
p.error_with_token_index('assigning `$expr` to `_` is redundant', assign_error_tok_idx)
|
p.error_with_token_index('assigning `$expr` to `_` is redundant', assign_error_tok_idx)
|
||||||
}
|
}
|
||||||
p.bool_expression()
|
|
||||||
or_else := p.tok == .key_orelse
|
or_else := p.tok == .key_orelse
|
||||||
//tmp := p.get_tmp()
|
//tmp := p.get_tmp()
|
||||||
if or_else {
|
if or_else {
|
||||||
|
Loading…
Reference in New Issue
Block a user