json grammar: fix support for empty strings
authorAlexis Laferrière <alexis.laf@xymus.net>
Wed, 2 Apr 2014 20:49:02 +0000 (16:49 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Wed, 2 Apr 2014 20:49:02 +0000 (16:49 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

contrib/nitcc/examples/json.sablecc
lib/simple_json_reader/json_lexer.nit

index 2992a17..d1e9c6b 100644 (file)
@@ -9,7 +9,7 @@ frac = '.' d+;
 exp = e d+;
 e = ('e'|'E') ('+'|'-')?;
 
-string = '"' (Any-'\\'-'"' | '\\'Any)+ '"';
+string = '"' (Any-'\\'-'"' | '\\'Any)* '"';
 
 blank = (' '|'\n'|'\t')+;
 
index 6600f52..78dee16 100644 (file)
@@ -36,7 +36,6 @@ redef class Object
        private fun dfastate_28: DFAState28 do return once new DFAState28
        private fun dfastate_29: DFAState29 do return once new DFAState29
        private fun dfastate_30: DFAState30 do return once new DFAState30
-       private fun dfastate_31: DFAState31 do return once new DFAState31
 end
 class MyNToken
        super NToken
@@ -93,11 +92,11 @@ class DFAState2
        super DFAState
        redef fun trans(char) do
                var c = char.ascii
-               if c <= 33 then return dfastate_29
-               if c <= 34 then return null
-               if c <= 91 then return dfastate_29
+               if c <= 33 then return dfastate_2
+               if c <= 34 then return dfastate_29
+               if c <= 91 then return dfastate_2
                if c <= 92 then return dfastate_30
-               return dfastate_29
+               return dfastate_2
        end
 end
 class DFAState3
@@ -380,24 +379,6 @@ class DFAState28
 end
 class DFAState29
        super DFAState
-       redef fun trans(char) do
-               var c = char.ascii
-               if c <= 33 then return dfastate_29
-               if c <= 34 then return dfastate_31
-               if c <= 91 then return dfastate_29
-               if c <= 92 then return dfastate_30
-               return dfastate_29
-       end
-end
-class DFAState30
-       super DFAState
-       redef fun trans(char) do
-               var c = char.ascii
-               return dfastate_29
-       end
-end
-class DFAState31
-       super DFAState
        redef fun is_accept do return true
        redef fun make_token(position, text) do
                var t = new Nstring
@@ -406,3 +387,10 @@ class DFAState31
                return t
        end
 end
+class DFAState30
+       super DFAState
+       redef fun trans(char) do
+               var c = char.ascii
+               return dfastate_2
+       end
+end