mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
compiler: fix interfaces after the recent tokens change
This commit is contained in:
parent
14a8d4ae3c
commit
dd58298500
@ -209,6 +209,15 @@ fn (p & Parser) peek() Token {
|
|||||||
return tok.tok
|
return tok.tok
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO remove dups
|
||||||
|
fn (p &Parser) prev_token() Tok {
|
||||||
|
return p.tokens[p.token_idx - 2]
|
||||||
|
}
|
||||||
|
|
||||||
|
fn (p &Parser) cur_tok() Tok {
|
||||||
|
return p.tokens[p.token_idx - 1]
|
||||||
|
}
|
||||||
|
|
||||||
fn (p &Parser) peek_token() Tok {
|
fn (p &Parser) peek_token() Tok {
|
||||||
if p.token_idx >= p.tokens.len - 2 {
|
if p.token_idx >= p.tokens.len - 2 {
|
||||||
return Tok{tok:Token.eof}
|
return Tok{tok:Token.eof}
|
||||||
@ -540,6 +549,7 @@ fn (p mut Parser) type_decl() {
|
|||||||
p.register_type_with_parent(name, parent.name)
|
p.register_type_with_parent(name, parent.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// current token is `(`
|
||||||
fn (p mut Parser) interface_method(field_name, receiver string) &Fn {
|
fn (p mut Parser) interface_method(field_name, receiver string) &Fn {
|
||||||
mut method := &Fn {
|
mut method := &Fn {
|
||||||
name: field_name
|
name: field_name
|
||||||
@ -549,8 +559,10 @@ fn (p mut Parser) interface_method(field_name, receiver string) &Fn {
|
|||||||
}
|
}
|
||||||
//p.log('is interface. field=$field_name run=$p.pass')
|
//p.log('is interface. field=$field_name run=$p.pass')
|
||||||
p.fn_args(mut method)
|
p.fn_args(mut method)
|
||||||
if p.scanner.has_gone_over_line_end() {
|
prev_tok := p.prev_token()
|
||||||
//if p.prev_tok.line_nr != p.tok.line_nr {
|
cur_tok := p.cur_tok()
|
||||||
|
// No type on the same line, this method doesn't return a type, process next
|
||||||
|
if prev_tok.line_nr != cur_tok.line_nr {
|
||||||
method.typ = 'void'
|
method.typ = 'void'
|
||||||
} else {
|
} else {
|
||||||
method.typ = p.get_type()// method return type
|
method.typ = p.get_type()// method return type
|
||||||
|
@ -228,20 +228,6 @@ fn (s mut Scanner) ident_number() string {
|
|||||||
return s.ident_dec_number()
|
return s.ident_dec_number()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (s Scanner) has_gone_over_line_end() bool {
|
|
||||||
mut i := s.pos-1
|
|
||||||
for i >= 0 && !s.text[i].is_white() {
|
|
||||||
i--
|
|
||||||
}
|
|
||||||
for i >= 0 && s.text[i].is_white() {
|
|
||||||
if is_nl(s.text[i]) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
i--
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
fn (s mut Scanner) skip_whitespace() {
|
fn (s mut Scanner) skip_whitespace() {
|
||||||
for s.pos < s.text.len && s.text[s.pos].is_white() {
|
for s.pos < s.text.len && s.text[s.pos].is_white() {
|
||||||
// Count \r\n as one line
|
// Count \r\n as one line
|
||||||
|
Loading…
Reference in New Issue
Block a user