nitcc: end-of-stream does not equate `'\0'`
authorJean Privat <jean@pryen.org>
Fri, 29 Nov 2013 14:32:04 +0000 (09:32 -0500)
committerJean Privat <jean@pryen.org>
Fri, 29 Nov 2013 14:32:04 +0000 (09:32 -0500)
It was a basic WIP stuff that remained.
`Any` and other classes of character can legally accept `'\0'` thus looping
infinitely.

Reported-by: Samuel Lambert <tweakedsam@gmail.com>
Signed-off-by: Jean Privat <jean@pryen.org>

lib/nitcc_runtime.nit

index b5fb0fb..1342c59 100644 (file)
@@ -186,12 +186,14 @@ abstract class Lexer
                                last_state = state
                        end
                        var c
+                       var next
                        if pos >= length then
                                c = '\0'
+                               next = null
                        else
                                c = text[pos]
+                               next = state.trans(c)
                        end
-                       var next = state.trans(c)
                        if next == null then
                                if pos_start < length then
                                        if last_state == null then