1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

vh types + fn receiver name check

This commit is contained in:
Alexander Medvednikov
2019-10-23 13:03:14 +03:00
parent 27e254c738
commit e69117a8f3
5 changed files with 61 additions and 24 deletions

View File

@ -9,14 +9,6 @@ import (
strings
)
struct Token {
tok TokenKind // the token number/enum; for quick comparisons
lit string // literal representation of the token
line_nr int // the line number in the source where the token occured
name_idx int // name table index for O(1) lookup
col int // the column where the token ends
}
struct Parser {
file_path_id string // unique id. if parsing file will be path eg, "/home/user/hello.v"
file_name string // "hello.v"
@ -532,7 +524,12 @@ fn (p mut Parser) const_decl() {
mut typ := ''
if p.is_vh {
// .vh files don't have const values, just types: `const (a int)`
typ = p.get_type()
if p.tok == .assign {
p.next()
typ = p.expression()
} else {
typ = p.get_type()
}
p.table.register_const(name, typ, p.mod)
p.cgen.consts << ('extern ' +
p.table.cgen_name_type_pair(name, typ)) + ';'