nitcc: add Empty keyword
authorJean Privat <jean@pryen.org>
Thu, 31 Oct 2013 14:27:17 +0000 (10:27 -0400)
committerJean Privat <jean@pryen.org>
Thu, 31 Oct 2013 14:27:17 +0000 (10:27 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

contrib/nitcc/README.md
contrib/nitcc/src/nitcc.sablecc
contrib/nitcc/tests/empty-alt.input1 [new file with mode: 0644]
contrib/nitcc/tests/empty-alt.sablecc [new file with mode: 0644]
contrib/nitcc/tests/sav/empty-alt.input1.res [new file with mode: 0644]

index c57dccc..aece084 100644 (file)
@@ -58,6 +58,7 @@ For the parser (and grammar and LR)
 [X] Modifiers (`?`, `*`, `+`)
 [X] Ignored
 [X] Rejected
+[X] Empty (but not mandatory)
 [ ] Opportunistic
 [ ] Precedence
 [ ] Separator
index a4e923b..63c77ff 100644 (file)
@@ -101,4 +101,5 @@ elem =
        {str:} str |
        {star:} elem '*' |
        {ques:} elem '?' |
-       {plus:} elem '+' ;
+       {plus:} elem '+' |
+       {empty:} 'Empty' ;
diff --git a/contrib/nitcc/tests/empty-alt.input1 b/contrib/nitcc/tests/empty-alt.input1
new file mode 100644 (file)
index 0000000..a9faff4
--- /dev/null
@@ -0,0 +1 @@
+qrstuvqrs1t1u1v1
\ No newline at end of file
diff --git a/contrib/nitcc/tests/empty-alt.sablecc b/contrib/nitcc/tests/empty-alt.sablecc
new file mode 100644 (file)
index 0000000..d547259
--- /dev/null
@@ -0,0 +1,10 @@
+Grammar empty;
+Parser
+ps = ps p | p;
+p = 'q' q 'r' r 's' s 't' t 'u' u 'v' v ;
+q = Empty;
+r = ;
+s = '1' | Empty;
+t = '1' | ;
+u = '1' | '2' | Empty;
+v = '1' | '2' | ;
diff --git a/contrib/nitcc/tests/sav/empty-alt.input1.res b/contrib/nitcc/tests/sav/empty-alt.input1.res
new file mode 100644 (file)
index 0000000..7160d35
--- /dev/null
@@ -0,0 +1,34 @@
+Start
+  ps_0
+    ps_1
+      p
+        'q'@(1:1-1:2)
+        q
+        'r'@(1:2-1:3)
+        r
+        's'@(1:3-1:4)
+        s_1
+        't'@(1:4-1:5)
+        t_1
+        'u'@(1:5-1:6)
+        u_2
+        'v'@(1:6-1:7)
+        v_2
+    p
+      'q'@(1:7-1:8)
+      q
+      'r'@(1:8-1:9)
+      r
+      's'@(1:9-1:10)
+      s_0
+        '1'@(1:10-1:11)
+      't'@(1:11-1:12)
+      t_0
+        '1'@(1:12-1:13)
+      'u'@(1:13-1:14)
+      u_0
+        '1'@(1:14-1:15)
+      'v'@(1:15-1:16)
+      v_0
+        '1'@(1:16-1:17)
+  Eof@(1:17-1:17)=''