comments support, script loading support
This commit is contained in:
parent
654e8bd55b
commit
bd22b84699
11 changed files with 145 additions and 69 deletions
18
ast/lex.go
18
ast/lex.go
|
|
@ -121,6 +121,17 @@ func lex(input string) *Token {
|
|||
return -2
|
||||
}
|
||||
|
||||
// returns the end of the string OR the end of the line
|
||||
matchLineEnd := func(start int) int {
|
||||
for i := start; i < len(input); i++ {
|
||||
if input[i] == '\n' {
|
||||
return i
|
||||
}
|
||||
}
|
||||
|
||||
return len(input)
|
||||
}
|
||||
|
||||
needs_alloc := false
|
||||
start_pos := 0
|
||||
for i := 0; i < len(input); i++ {
|
||||
|
|
@ -137,13 +148,18 @@ func lex(input string) *Token {
|
|||
is_str = true
|
||||
needs_alloc = true
|
||||
|
||||
case ' ':
|
||||
case ' ', '\n', '\t', '\v', '\f', '\r':
|
||||
if i == start_pos {
|
||||
start_pos += 1
|
||||
continue
|
||||
}
|
||||
|
||||
needs_alloc = true
|
||||
|
||||
// comment case
|
||||
case ';':
|
||||
start_pos = i + 1
|
||||
i = matchLineEnd(start_pos)
|
||||
}
|
||||
|
||||
if needs_alloc {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue