comments support, script loading support

This commit is contained in:
Aidan 2020-07-15 18:41:54 -07:00
parent 654e8bd55b
commit bd22b84699
No known key found for this signature in database
GPG key ID: 327711E983899316
11 changed files with 145 additions and 69 deletions

View file

@ -61,6 +61,8 @@ func (in *Token) Eval(funcs FuncTable, vars VarTable, cnvtUndefVars bool) *Token
"eval")
return nil
}
} else {
res.Next = in.Next
}
case LIST:

View file

@ -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 {