parser: fix silent errors (#7271)
parent
a26e1e6e13
commit
11808f9fa3
|
@ -612,3 +612,5 @@ jobs:
|
||||||
./v test-parser examples/cli.v
|
./v test-parser examples/cli.v
|
||||||
./v test-parser examples/json.v
|
./v test-parser examples/json.v
|
||||||
./v test-parser examples/vmod.v
|
./v test-parser examples/vmod.v
|
||||||
|
./v test-parser examples/regex_example.v
|
||||||
|
./v test-parser examples/2048/2048.v
|
||||||
|
|
|
@ -47,7 +47,7 @@ struct Theme {
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
themes = [
|
themes = [
|
||||||
&Theme{
|
&Theme{
|
||||||
bg_color: gx.rgb(250, 248, 239)
|
bg_color: gx.rgb(250, 248, 239)
|
||||||
padding_color: gx.rgb(143, 130, 119)
|
padding_color: gx.rgb(143, 130, 119)
|
||||||
|
|
|
@ -38,7 +38,7 @@ fn (mut p Parser) array_init() ast.ArrayInit {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// [1,2,3] or [const]byte
|
// [1,2,3] or [const]byte
|
||||||
for i := 0; p.tok.kind != .rsbr; i++ {
|
for i := 0; p.tok.kind !in [.rsbr, .eof]; i++ {
|
||||||
exprs << p.expr(0)
|
exprs << p.expr(0)
|
||||||
ecmnts << p.eat_comments()
|
ecmnts << p.eat_comments()
|
||||||
if p.tok.kind == .comma {
|
if p.tok.kind == .comma {
|
||||||
|
|
|
@ -14,6 +14,10 @@ pub fn (mut p Parser) parse_array_type() table.Type {
|
||||||
p.next()
|
p.next()
|
||||||
p.check(.rsbr)
|
p.check(.rsbr)
|
||||||
elem_type := p.parse_type()
|
elem_type := p.parse_type()
|
||||||
|
if elem_type.idx() == 0 {
|
||||||
|
// error is handled by parse_type
|
||||||
|
return 0
|
||||||
|
}
|
||||||
// sym := p.table.get_type_symbol(elem_type)
|
// sym := p.table.get_type_symbol(elem_type)
|
||||||
idx := p.table.find_or_register_array_fixed(elem_type, size, 1)
|
idx := p.table.find_or_register_array_fixed(elem_type, size, 1)
|
||||||
return table.new_type(idx)
|
return table.new_type(idx)
|
||||||
|
@ -72,7 +76,7 @@ pub fn (mut p Parser) parse_chan_type() table.Type {
|
||||||
pub fn (mut p Parser) parse_multi_return_type() table.Type {
|
pub fn (mut p Parser) parse_multi_return_type() table.Type {
|
||||||
p.check(.lpar)
|
p.check(.lpar)
|
||||||
mut mr_types := []table.Type{}
|
mut mr_types := []table.Type{}
|
||||||
for {
|
for p.tok.kind != .eof {
|
||||||
mr_type := p.parse_type()
|
mr_type := p.parse_type()
|
||||||
mr_types << mr_type
|
mr_types << mr_type
|
||||||
if p.tok.kind == .comma {
|
if p.tok.kind == .comma {
|
||||||
|
@ -219,7 +223,7 @@ pub fn (mut p Parser) parse_any_type(language table.Language, is_ptr bool, check
|
||||||
p.check(.dot)
|
p.check(.dot)
|
||||||
// prefix with full module
|
// prefix with full module
|
||||||
name = '${p.imports[name]}.$p.tok.lit'
|
name = '${p.imports[name]}.$p.tok.lit'
|
||||||
if !p.tok.lit[0].is_capital() {
|
if p.tok.lit.len > 0 && !p.tok.lit[0].is_capital() {
|
||||||
p.error('imported types must start with a capital letter')
|
p.error('imported types must start with a capital letter')
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
|
@ -2102,7 +2102,7 @@ fn (mut p Parser) assoc() ast.Assoc {
|
||||||
mut fields := []string{}
|
mut fields := []string{}
|
||||||
mut vals := []ast.Expr{}
|
mut vals := []ast.Expr{}
|
||||||
p.check(.pipe)
|
p.check(.pipe)
|
||||||
for {
|
for p.tok.kind != .eof {
|
||||||
fields << p.check_name()
|
fields << p.check_name()
|
||||||
p.check(.colon)
|
p.check(.colon)
|
||||||
expr := p.expr(0)
|
expr := p.expr(0)
|
||||||
|
|
|
@ -890,10 +890,12 @@ fn (mut s Scanner) text_scan() token.Token {
|
||||||
if nextc == `=` {
|
if nextc == `=` {
|
||||||
s.pos++
|
s.pos++
|
||||||
return s.new_token(.ne, '', 2)
|
return s.new_token(.ne, '', 2)
|
||||||
} else if nextc == `i` && s.text[s.pos + 2] == `n` && s.text[s.pos + 3].is_space() {
|
} else if s.text.len > s.pos + 3 &&
|
||||||
|
nextc == `i` && s.text[s.pos + 2] == `n` && s.text[s.pos + 3].is_space() {
|
||||||
s.pos += 2
|
s.pos += 2
|
||||||
return s.new_token(.not_in, '', 3)
|
return s.new_token(.not_in, '', 3)
|
||||||
} else if nextc == `i` && s.text[s.pos + 2] == `s` && s.text[s.pos + 3].is_space() {
|
} else if s.text.len > s.pos + 3 &&
|
||||||
|
nextc == `i` && s.text[s.pos + 2] == `s` && s.text[s.pos + 3].is_space() {
|
||||||
s.pos += 2
|
s.pos += 2
|
||||||
return s.new_token(.not_is, '', 3)
|
return s.new_token(.not_is, '', 3)
|
||||||
} else {
|
} else {
|
||||||
|
@ -943,7 +945,7 @@ fn (mut s Scanner) text_scan() token.Token {
|
||||||
start := s.pos + 2
|
start := s.pos + 2
|
||||||
mut nest_count := 1
|
mut nest_count := 1
|
||||||
// Skip comment
|
// Skip comment
|
||||||
for nest_count > 0 {
|
for nest_count > 0 && s.pos < s.text.len - 1 {
|
||||||
s.pos++
|
s.pos++
|
||||||
if s.pos >= s.text.len {
|
if s.pos >= s.text.len {
|
||||||
s.line_nr--
|
s.line_nr--
|
||||||
|
|
Loading…
Reference in New Issue