Skip to content

Commit

Permalink
nitcc: test Separator and Tail
Browse files Browse the repository at this point in the history
Signed-off-by: Jean Privat <[email protected]>
  • Loading branch information
privat committed Jun 23, 2024
1 parent fd60093 commit e967536
Show file tree
Hide file tree
Showing 12 changed files with 362 additions and 72 deletions.
7 changes: 7 additions & 0 deletions contrib/nitcc/tests/parser-separator.input
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
s a b a
s a b a b a
s a
s a c d e a c
s a c d e a c d e a c
s a c
s a c d e
10 changes: 10 additions & 0 deletions contrib/nitcc/tests/parser-separator.sablecc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Grammar gram;
Lexer
blank = #10 | #13 | #32;
Parser
Ignored blank;
s =
s 's' ('a' Separator 'b')+ |
s 's' ('a' 'c' Separator 'd' 'e')+ |
s 's' ('b' Separator 'c')* |
Empty;
10 changes: 10 additions & 0 deletions contrib/nitcc/tests/parser-tail.input
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
s a b a
s a b
s a b a b a
s a b a b
s a
s a c d e a c
s a c d e a c d e a c
s a c
s a c d e
s a c d e a c d e
10 changes: 10 additions & 0 deletions contrib/nitcc/tests/parser-tail.sablecc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Grammar gram;
Lexer
blank = #10 | #13 | #32;
Parser
Ignored blank;
s =
s 's' ('a' Tail 'b')+ |
s 's' ('a' 'c' Tail 'd' 'e')+ |
s 's' ('b' Tail 'c')* |
Empty;
136 changes: 95 additions & 41 deletions contrib/nitcc/tests/sav/inf5000-06-grammaire2-grammaire2.input.res
Original file line number Diff line number Diff line change
@@ -1,41 +1,95 @@
T_Id@1,1:prods
TAnonymous@1,7:=
T_Altid@1,9:{many:}
T_Id@1,17:prods
T_Id@1,23:prod
TAnonymous@1,29:|
T_Altid@1,31:{one:}
T_Id@1,38:prod
TAnonymous@1,43:;
T_Id@2,1:prod
TAnonymous@2,6:=
T_Id@2,8:id
T_Str@2,11:'='
T_Id@2,15:alts
T_Str@2,20:';'
TAnonymous@2,24:;
T_Id@3,1:alts
TAnonymous@3,6:=
T_Altid@3,8:{many:}
T_Id@3,16:alts
T_Str@3,21:'|'
T_Id@3,25:alt
TAnonymous@3,29:|
T_Altid@3,31:{one:}
T_Id@3,38:alt
TAnonymous@3,42:;
T_Id@4,1:alt
TAnonymous@4,5:=
T_Id@4,7:altid
T_Id@4,13:atoms
TAnonymous@4,19:|
T_Id@4,21:atoms
TAnonymous@4,27:;
T_Id@5,1:atoms
TAnonymous@5,7:=
T_Altid@5,9:{many:}
T_Id@5,17:atoms
T_Id@5,23:atom
TAnonymous@5,28:|
T_Altid@5,30:{none:}
5,38. Syntax error: Unexpected character 'E'.
NLexerError@(5:38-5:38)='E'
Nodes[Node]
Nodes[Nprod]
prod
id@(1:1-1:6)='prods'
'='@(1:7-1:8)
Nodes[N_group1]
_group1_single
alt
altid@(1:9-1:16)='{many:}'
Nodes[Natom]
atom_id
id@(1:17-1:22)='prods'
atom_id
id@(1:23-1:27)='prod'
'|'@(1:29-1:30)
_group0_single
alt
altid@(1:31-1:37)='{one:}'
Nodes[Natom]
atom_id
id@(1:38-1:42)='prod'
';'@(1:43-1:44)
prod
id@(2:1-2:5)='prod'
'='@(2:6-2:7)
Nodes[N_group1]
_group0_single
alt
Nodes[Natom]
atom_id
id@(2:8-2:10)='id'
atom_str
str@(2:11-2:14)='\'=\''
atom_id
id@(2:15-2:19)='alts'
atom_str
str@(2:20-2:23)='\';\''
';'@(2:24-2:25)
prod
id@(3:1-3:5)='alts'
'='@(3:6-3:7)
Nodes[N_group1]
_group1_single
alt
altid@(3:8-3:15)='{many:}'
Nodes[Natom]
atom_id
id@(3:16-3:20)='alts'
atom_str
str@(3:21-3:24)='\'|\''
atom_id
id@(3:25-3:28)='alt'
'|'@(3:29-3:30)
_group0_single
alt
altid@(3:31-3:37)='{one:}'
Nodes[Natom]
atom_id
id@(3:38-3:41)='alt'
';'@(3:42-3:43)
prod
id@(4:1-4:4)='alt'
'='@(4:5-4:6)
Nodes[N_group1]
_group1_single
alt
Nodes[Natom]
atom_id
id@(4:7-4:12)='altid'
atom_id
id@(4:13-4:18)='atoms'
'|'@(4:19-4:20)
_group0_single
alt
Nodes[Natom]
atom_id
id@(4:21-4:26)='atoms'
';'@(4:27-4:28)
id@(5:1-5:6)='atoms'
'='@(5:7-5:8)
Nodes[N_group1]
_group1_single
alt
altid@(5:9-5:16)='{many:}'
Nodes[Natom]
atom_id
id@(5:17-5:22)='atoms'
atom_id
id@(5:23-5:27)='atom'
'|'@(5:28-5:29)
_group0_single
alt
altid@(5:30-5:37)='{none:}'
NLexerError@(5:38-5:38)='E'
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
11:15-11:16 Syntax Error: Unexpected '('; is acceptable instead: priority+, priority
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
T_Id@1,1:x
TAnonymous@1,3:=
T_Id@1,5:y
TAnonymous@1,6:;
TAnonymous@2,1:while
TAnonymous@2,7:(
T_Id@2,8:z
TAnonymous@2,9:)
TAnonymous@2,11:{
TAnonymous@2,13:print
T_Id@2,19:t
TAnonymous@2,20:;
T_Id@2,22:k
TAnonymous@2,23:=
T_Id@2,24:u
TAnonymous@2,25:;
TAnonymous@2,27:}
TEnd@3,1:
Start
prog
Nodes[Nstmt]
stmt_assign
id@(1:1-1:2)='x'
'='@(1:3-1:4)
expr
id@(1:5-1:6)='y'
';'@(1:6-1:7)
stmt_while
'while'@(2:1-2:6)
'('@(2:7-2:8)
expr
id@(2:8-2:9)='z'
')'@(2:9-2:10)
'{'@(2:11-2:12)
Nodes[Nstmt]
stmt_print
'print'@(2:13-2:18)
'('@(2:18-2:19)
expr
id@(2:19-2:20)='t'
')'@(2:20-2:21)
';'@(2:21-2:22)
stmt_assign
id@(2:23-2:24)='k'
'='@(2:24-2:25)
expr
id@(2:25-2:26)='u'
';'@(2:26-2:27)
'}'@(2:28-2:29)
Eof@(3:1-3:1)=''
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
20:8-20:9 Syntax Error: Unexpected '('; is acceptable instead: priority+, priority
44 changes: 34 additions & 10 deletions contrib/nitcc/tests/sav/inf5000-06-grammaire2-polygone.input.res
Original file line number Diff line number Diff line change
@@ -1,10 +1,34 @@
TAnonymous@1,1:(
TAnonymous@1,2:(
T_Num@1,3:0
TAnonymous@1,4:x
TAnonymous@1,5:,
T_Num@1,6:0
TAnonymous@1,7:y
TAnonymous@1,8:)
TAnonymous@1,9:,
1,10. Syntax error: Unexpected character ' '.
Start
polygone
'('@(1:1-1:2)
Nodes[N_group1]
_group1_single
point_cart
'('@(1:2-1:3)
num@(1:3-1:4)='0'
'x'@(1:4-1:5)
','@(1:5-1:6)
num@(1:6-1:7)='0'
'y'@(1:7-1:8)
')'@(1:8-1:9)
','@(1:9-1:10)
_group1_single
point_pol
'('@(1:11-1:12)
num@(1:12-1:14)='10'
','@(1:14-1:15)
num@(1:16-1:17)='0'
'deg'@(1:17-1:20)
')'@(1:20-1:21)
','@(1:21-1:22)
_group0_single
point_cart
'('@(1:23-1:24)
num@(1:24-1:25)='0'
'x'@(1:25-1:26)
','@(1:26-1:27)
num@(1:28-1:30)='10'
'y'@(1:30-1:31)
')'@(1:31-1:32)
')'@(1:32-1:33)
Eof@(2:1-2:1)=''
1 change: 0 additions & 1 deletion contrib/nitcc/tests/sav/inf5000-06-grammaire2-polygone.res
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
8:18-8:19 Syntax Error: Unexpected '('; is acceptable instead: priority+, priority
68 changes: 68 additions & 0 deletions contrib/nitcc/tests/sav/parser-separator.input.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
NParserError@(8:1-8:1)=''
Nodes[Node]
s_1
s_1
s_1
s_0
s_0
s_0
s_3
's'@(1:1-1:2)
Nodes[N_group1]
_group1_single
'a'@(1:3-1:4)
'b'@(1:5-1:6)
_group0_single
'a'@(1:7-1:8)
's'@(2:1-2:2)
Nodes[N_group1]
_group1_single
'a'@(2:3-2:4)
'b'@(2:5-2:6)
_group1_single
'a'@(2:7-2:8)
'b'@(2:9-2:10)
_group0_single
'a'@(2:11-2:12)
's'@(3:1-3:2)
Nodes[N_group1]
_group0_single
'a'@(3:3-3:4)
's'@(4:1-4:2)
Nodes[N_group3]
_group3_single
'a'@(4:3-4:4)
'c'@(4:5-4:6)
'd'@(4:7-4:8)
'e'@(4:9-4:10)
_group2_single
'a'@(4:11-4:12)
'c'@(4:13-4:14)
's'@(5:1-5:2)
Nodes[N_group3]
_group3_single
'a'@(5:3-5:4)
'c'@(5:5-5:6)
'd'@(5:7-5:8)
'e'@(5:9-5:10)
_group3_single
'a'@(5:11-5:12)
'c'@(5:13-5:14)
'd'@(5:15-5:16)
'e'@(5:17-5:18)
_group2_single
'a'@(5:19-5:20)
'c'@(5:21-5:22)
's'@(6:1-6:2)
Nodes[N_group3]
_group2_single
'a'@(6:3-6:4)
'c'@(6:5-6:6)
's'@(7:1-7:2)
Nodes[N_group3]
_group3_single
'a'@(7:3-7:4)
'c'@(7:5-7:6)
'd'@(7:7-7:8)
'e'@(7:9-7:10)
Eof@(8:1-8:1)=''
Loading

0 comments on commit e967536

Please sign in to comment.