Updates lexer to allow 'end' instead of '.' if desired
This commit is contained in:
parent
90c8e16997
commit
4488d8b909
4
lexer.go
4
lexer.go
|
@ -71,7 +71,9 @@ TokenizationLoop:
|
|||
// in a map of built-ins
|
||||
if isKeyword(wn.val.(string)) {
|
||||
wn.kind = KEYWORD
|
||||
}
|
||||
} else if wn.val.(string) == "end" {
|
||||
wn = token{END, false, fileLine, f}
|
||||
}
|
||||
}
|
||||
tokens = append(tokens, wn)
|
||||
}
|
||||
|
|
10
test.fe
10
test.fe
|
@ -12,7 +12,7 @@ proc fib
|
|||
INT var! s
|
||||
|
||||
proc continue-loop?
|
||||
fib# 0 > .
|
||||
fib# 0 > end
|
||||
|
||||
continue-loop?
|
||||
while
|
||||
|
@ -20,8 +20,8 @@ proc fib
|
|||
b set! a
|
||||
s set! b
|
||||
fib# 1 - set! fib#
|
||||
continue-loop? .
|
||||
a .
|
||||
continue-loop? end
|
||||
a end
|
||||
|
||||
# run it!
|
||||
sys-args length 0 >
|
||||
|
@ -30,9 +30,9 @@ if
|
|||
sys-args 1 list-get INT cast fib println
|
||||
else
|
||||
"No input\n" stderr file-write
|
||||
.
|
||||
end
|
||||
|
||||
. <-- This dot concludes reading of the file so
|
||||
end <-- This dot concludes reading of the file so
|
||||
anything below is just comment space that will
|
||||
not be read by the interpreter. Dots always
|
||||
close off a given scope. Since we were in the
|
||||
|
|
Loading…
Reference in New Issue