Skip to content

Commit

Permalink
nitcc: results store shift and reduce conflicts
Browse files Browse the repository at this point in the history
Signed-off-by: Jean Privat <[email protected]>
  • Loading branch information
privat committed Jul 21, 2024
1 parent 0cf94a5 commit c4c208d
Show file tree
Hide file tree
Showing 27 changed files with 327 additions and 71 deletions.
2 changes: 1 addition & 1 deletion contrib/nitcc/src/lrautomaton.nit
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ class LRState
end
if confs.is_empty then
print "---"
print "Automatic Dangling on state {self} for token {t}:"
print "Automatic Dangling SHIFT/REDUCE on state {self} for token {t}:"
print "\treduce: {ri}"
for r in ress do print r
removed_reduces.add t
Expand Down
6 changes: 6 additions & 0 deletions contrib/nitcc/tests/sav/amb.res
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
REDUCE/REDUCE Conflict on state 1 e for token Eof:
REDUCE on item: e→ e·, Eof
REDUCE on item: e→ e·, Eof
SHIFT/REDUCE Conflict on state 1 e for token Eof:
SHIFT on item: _start→ e·Eof
REDUCE on item: e→ e·, Eof
Error: there is conflicts
3 changes: 3 additions & 0 deletions contrib/nitcc/tests/sav/amb2.res
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
REDUCE/REDUCE Conflict on state 7 '-' e for token '+':
REDUCE on item: a→ e·, Eof/'+'
REDUCE on item: b→ e·, '+'
Error: there is conflicts
3 changes: 3 additions & 0 deletions contrib/nitcc/tests/sav/amb3.res
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
SHIFT/REDUCE Conflict on state 3 'a' for token 'b':
SHIFT on item: x→·'b', Eof
REDUCE on item: x→ 'a'·, 'b'
Error: there is conflicts
3 changes: 3 additions & 0 deletions contrib/nitcc/tests/sav/conflict-bracket.res
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
SHIFT/REDUCE Conflict on state 8 '[' e '[' for token '[':
SHIFT on item: e→·'[' e '[', ']'/'['
REDUCE on item: e→ '[' e '['·, Eof/'['/']'
Error: there is conflicts
3 changes: 3 additions & 0 deletions contrib/nitcc/tests/sav/conflict-dangling.1alt1.alt1.res
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
SHIFT/REDUCE Conflict on state 7 '1' e for token '2':
SHIFT on item: x→·'2', Eof/'2'
REDUCE on item: e→ '1' e·, Eof/'2'
Error: there is conflicts
3 changes: 3 additions & 0 deletions contrib/nitcc/tests/sav/conflict-dangling.1alt1.alt2.res
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
SHIFT/REDUCE Conflict on state 7 '1' e for token '2':
SHIFT on item: x→·'2', Eof/'2'
REDUCE on item: y→·, Eof/'2'
Error: there is conflicts
3 changes: 3 additions & 0 deletions contrib/nitcc/tests/sav/conflict-dangling.1alt1.res
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
SHIFT/REDUCE Conflict on state 7 '1' e for token '2':
SHIFT on item: e→ '1' e·'2', Eof/'2'
REDUCE on item: e→ '1' e·, Eof/'2'
Error: there is conflicts
4 changes: 4 additions & 0 deletions contrib/nitcc/tests/sav/conflict-dangling.alt1.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Automatic Dangling SHIFT/REDUCE on state 6 '1' e for token '2':
reduce: e→ '1' e·, Eof/'2'
shift: x→·'2'
core shift: e→ '1' e·x, Eof/'2'
4 changes: 4 additions & 0 deletions contrib/nitcc/tests/sav/conflict-dangling.alt2.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Automatic Dangling SHIFT/REDUCE on state 6 '1' e for token '2':
reduce: y→·, Eof/'2'
shift: x→·'2'
core shift: y→·x, Eof/'2'
3 changes: 3 additions & 0 deletions contrib/nitcc/tests/sav/conflict-dangling.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Automatic Dangling SHIFT/REDUCE on state 6 '1' e for token '2':
reduce: e→ '1' e·, Eof/'2'
shift: e→ '1' e·'2'
3 changes: 3 additions & 0 deletions contrib/nitcc/tests/sav/eq2.res
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
SHIFT/REDUCE Conflict on state 2 var for token '=':
SHIFT on item: e→ var·'=' e, Eof/'='
REDUCE on item: e→ var·, Eof/'='
Error: there is conflicts
9 changes: 9 additions & 0 deletions contrib/nitcc/tests/sav/eq3.res
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
SHIFT/REDUCE Conflict on state 2 var for token '=':
SHIFT on item: e→ var·'=' e, Eof/'='
REDUCE on item: e→ var·, '='/Eof
Automatic Dangling SHIFT/REDUCE on state 8 e '=' e for token '=':
reduce: c→ e '=' e·, Eof/'='
shift: c→ e·'=' e
SHIFT/REDUCE Conflict on state 9 var '=' e for token '=':
SHIFT on item: c→ e·'=' e, Eof/'='
REDUCE on item: e→ var '=' e·, Eof/'='
Error: there is conflicts
7 changes: 7 additions & 0 deletions contrib/nitcc/tests/sav/if.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Automatic Dangling SHIFT/REDUCE on state 15 'e' 'if' e 'then' e for token 'else':
reduce: e'if' e 'then' e·, Eof/'then'/'else'
shift: else→·'else' e
core shift: e'if' e 'then' e·else, Eof/'then'/'else'
Automatic Dangling SHIFT/REDUCE on state 16 'f' 'if' f 'then' f for token 'else':
reduce: f'if' f 'then' f·, Eof/'then'/'else'
shift: f'if' f 'then' f·'else' f
27 changes: 27 additions & 0 deletions contrib/nitcc/tests/sav/inf5000-05-grammaire-arithmetique.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Automatic Dangling SHIFT/REDUCE on state 12 exp '+' exp for token '+':
reduce: expexp '+' exp·, Eof/'+'/'-'/'*'/int/'('/')'
shift: expexp·'+' exp
Automatic Dangling SHIFT/REDUCE on state 12 exp '+' exp for token '-':
reduce: expexp '+' exp·, Eof/'+'/'-'/'*'/int/'('/')'
shift: expexp·'-' exp
Automatic Dangling SHIFT/REDUCE on state 12 exp '+' exp for token '*':
reduce: expexp '+' exp·, Eof/'+'/'-'/'*'/int/'('/')'
shift: expexp·'*' exp
Automatic Dangling SHIFT/REDUCE on state 13 exp '-' exp for token '+':
reduce: expexp '-' exp·, '+'/'*'/'-'/Eof/int/'('/')'
shift: expexp·'+' exp
Automatic Dangling SHIFT/REDUCE on state 13 exp '-' exp for token '*':
reduce: expexp '-' exp·, '+'/'*'/'-'/Eof/int/'('/')'
shift: expexp·'*' exp
Automatic Dangling SHIFT/REDUCE on state 13 exp '-' exp for token '-':
reduce: expexp '-' exp·, '+'/'*'/'-'/Eof/int/'('/')'
shift: expexp·'-' exp
Automatic Dangling SHIFT/REDUCE on state 14 exp '*' exp for token '+':
reduce: expexp '*' exp·, '+'/'-'/'*'/Eof/int/'('/')'
shift: expexp·'+' exp
Automatic Dangling SHIFT/REDUCE on state 14 exp '*' exp for token '-':
reduce: expexp '*' exp·, '+'/'-'/'*'/Eof/int/'('/')'
shift: expexp·'-' exp
Automatic Dangling SHIFT/REDUCE on state 14 exp '*' exp for token '*':
reduce: expexp '*' exp·, '+'/'-'/'*'/Eof/int/'('/')'
shift: expexp·'*' exp
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,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)=''
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)=''
3 changes: 3 additions & 0 deletions contrib/nitcc/tests/sav/lg.res
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
SHIFT/REDUCE Conflict on state 12 '<' e '>' for token '<':
SHIFT on item: a→·'<' e '>', '<'/'>'
REDUCE on item: a→ '<' e '>'·, '<'/'>'/Eof
Error: there is conflicts
15 changes: 15 additions & 0 deletions contrib/nitcc/tests/sav/lg2.res
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
Automatic Dangling SHIFT/REDUCE on state 9 e '<' e for token '<':
reduce: e→ e '<' e·, Eof/'<'/'>'
shift: e→ e·'<' e
SHIFT/REDUCE Conflict on state 9 e '<' e for token '>':
SHIFT on item: e→ e·'>' e, '<'/'>'/Eof
REDUCE on item: e→ e '<' e·, Eof/'<'/'>'
Automatic Dangling SHIFT/REDUCE on state 10 e '>' e for token '<':
reduce: e→ e '>' e·, '<'/'>'/Eof
shift: e→ e·'<' e
SHIFT/REDUCE Conflict on state 10 e '>' e for token '>':
SHIFT on item: e→ e·'>' e, '<'/'>'/Eof
REDUCE on item: e→ e '>' e·, '<'/'>'/Eof
SHIFT/REDUCE Conflict on state 11 '<' e '>' for token '<':
SHIFT on item: e→·'<' e '>', '>'/'<'
REDUCE on item: e→ '<' e '>'·, '<'/'>'/Eof
Error: there is conflicts
3 changes: 3 additions & 0 deletions contrib/nitcc/tests/sav/lr1.res
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
REDUCE/REDUCE Conflict on state 3 'x' for token 'a':
REDUCE on item: q→ 'x'·, 'a'
REDUCE on item: r→ 'x'·, 'a'
Error: there is conflicts
13 changes: 13 additions & 0 deletions contrib/nitcc/tests/sav/nit_expr.res
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
SHIFT/REDUCE Conflict on state 3 'id' for token '[':
SHIFT on item: e→·'[' e ']', '['/Eof/']'/'..'
SHIFT on item: e→·'[' e '..' e '[', '['/Eof/']'/'..'
SHIFT on item: e→·'[' e '..' e ']', '['/Eof/']'/'..'
REDUCE on item: e→ 'id'·, '['/Eof/']'/'..'
SHIFT/REDUCE Conflict on state 7 'id' e for token '[':
SHIFT on item: e→ e·'[' e ']', '['/Eof/']'/'..'
REDUCE on item: e→ 'id' e·, '['/Eof/']'/'..'
SHIFT/REDUCE Conflict on state 13 '[' e '..' e '[' for token '[':
SHIFT on item: e→·'[' e ']', '['/']'
SHIFT on item: e→·'[' e '..' e '[', '['/']'
SHIFT on item: e→·'[' e '..' e ']', '['/']'
REDUCE on item: e→ '[' e '..' e '['·, '['/Eof/']'/'..'
Error: there is conflicts
6 changes: 6 additions & 0 deletions contrib/nitcc/tests/sav/not_lalr.res
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
REDUCE/REDUCE Conflict on state 7 'a' 'a' for token 'a':
REDUCE on item: x'a'·, 'a'/'b'
REDUCE on item: y'a'·, 'b'/'a'
REDUCE/REDUCE Conflict on state 7 'a' 'a' for token 'b':
REDUCE on item: x'a'·, 'a'/'b'
REDUCE on item: y'a'·, 'b'/'a'
Error: there is conflicts
Loading

0 comments on commit c4c208d

Please sign in to comment.