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

@ -4,6 +4,15 @@
module compiler
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
}
enum TokenKind {
eof
name // user
@ -281,6 +290,9 @@ fn (t []TokenKind) contains(val TokenKind) bool {
}
fn (t Token) str() string {
if t.tok == .str {
return "'$t.lit'"
}
if t.tok < .plus {
return t.lit // string, number etc
}