diff --git a/contrib/nitcc/src/grammar.nit b/contrib/nitcc/src/grammar.nit index 1213788418..4929198792 100644 --- a/contrib/nitcc/src/grammar.nit +++ b/contrib/nitcc/src/grammar.nit @@ -663,6 +663,9 @@ class Token do return to_s end + + # Unexpected occurences of this token do not cause a syntax error but are ignored. + var occasional = false is writable end # A alternative with a cursor (dot) before an element diff --git a/contrib/nitcc/src/lrautomaton.nit b/contrib/nitcc/src/lrautomaton.nit index 6a955fde32..300f9d8295 100644 --- a/contrib/nitcc/src/lrautomaton.nit +++ b/contrib/nitcc/src/lrautomaton.nit @@ -365,17 +365,17 @@ redef class Generator end add "redef class NToken" + add "\t# Default action on any state" + add "\tprivate fun action_default(parser: Parser) do" + add "\t\tparser.parse_error" + add "\tend" + for s in states do if not s.need_guard then continue add "\t# guarded action for state {s}" add "\t# {s.shifts.length} shift(s) and {s.reduces.length} reduce(s)" add "\tprivate fun action_s{s.number}(parser: Parser) do" - if s.reduces.length != 1 then - add "\t\tparser.parse_error" - else - add "\t\treduce_{s.reduces.first.cname}(parser)" - #gen_reduce_to_nit(s.reduces.first) - end + add "\t\taction_default(parser)" add "\tend" end add "end" @@ -390,12 +390,16 @@ redef class Generator end for s in t.reduces do if not s.need_guard then continue - if s.reduces.length <= 1 then continue add "\tredef fun action_s{s.number}(parser) do" add "\t\treduce_{s.guarded_reduce[t].first.alt.cname}(parser)" #gen_reduce_to_nit(s.guarded_reduce[t].first.alt) add "\tend" end + if t.occasional then + add "\tredef fun action_default(parser) do" + add "\t\tparser.get_token" + add "\tend" + end add "end" end diff --git a/contrib/nitcc/src/nitcc.sablecc b/contrib/nitcc/src/nitcc.sablecc index 80fac2d696..0cb4d9d629 100644 --- a/contrib/nitcc/src/nitcc.sablecc +++ b/contrib/nitcc/src/nitcc.sablecc @@ -80,10 +80,10 @@ text {-> re} = {ch_dec:} ch_dec | {ch_hex:} ch_hex ; -parser_part = 'Parser' ign? rej? prod*; +parser_part = 'Parser' ign? occasional? rej? prod*; ign = 'Ignored' elem_list ';' ; - +occasional = 'Occasional' elem_list ';' ; rej = 'Rejected' elem_list ';' ; prod = id ptrans? '=' alts priority* ';'; diff --git a/contrib/nitcc/src/nitcc_semantic.nit b/contrib/nitcc/src/nitcc_semantic.nit index 5021411cb1..f78084cea6 100644 --- a/contrib/nitcc/src/nitcc_semantic.nit +++ b/contrib/nitcc/src/nitcc_semantic.nit @@ -116,6 +116,9 @@ private class CheckNameVisitor # Known ignored tokens var ignoreds = new Array[Element] + # Known occasional tokens + var occasionals = new Array[Element] + # Known rejected tokens var rejecteds = new Array[Element] @@ -244,6 +247,25 @@ redef class Nign end end +redef class Noccasional + redef fun accept_check_name_visitor(v) do + # Add elements to the ignored list + v.elems = v.occasionals + super + for e in v.elems do + if e isa Production then + print "Error: cannot ignore {e}, it is a production" + exit(1) + abort + else if e isa Token then + e.occasional = true + else + abort + end + end + end +end + redef class Nrej redef fun accept_check_name_visitor(v) do # Add elements to the rejected list diff --git a/contrib/nitcc/tests/occasional.input b/contrib/nitcc/tests/occasional.input new file mode 100644 index 0000000000..2c75f43553 --- /dev/null +++ b/contrib/nitcc/tests/occasional.input @@ -0,0 +1 @@ +abbabbaa diff --git a/contrib/nitcc/tests/occasional.sablecc b/contrib/nitcc/tests/occasional.sablecc new file mode 100644 index 0000000000..34f9ded838 --- /dev/null +++ b/contrib/nitcc/tests/occasional.sablecc @@ -0,0 +1,5 @@ +Parser +Ignored #10, #32; +Occasional 'b'; +s = s e | e; +e = 'a' 'a' | 'b' ; diff --git a/contrib/nitcc/tests/occasional2.input b/contrib/nitcc/tests/occasional2.input new file mode 100644 index 0000000000..2c75f43553 --- /dev/null +++ b/contrib/nitcc/tests/occasional2.input @@ -0,0 +1 @@ +abbabbaa diff --git a/contrib/nitcc/tests/occasional2.sablecc b/contrib/nitcc/tests/occasional2.sablecc new file mode 100644 index 0000000000..d61fb46cd6 --- /dev/null +++ b/contrib/nitcc/tests/occasional2.sablecc @@ -0,0 +1,6 @@ +Parser +Ignored #10, #32; +Occasional 'b'; +s = s e | e; +e = 'a' 'a' | b ; +b = 'b' ; diff --git a/contrib/nitcc/tests/oneliner3.input b/contrib/nitcc/tests/oneliner3.input new file mode 100644 index 0000000000..521cbdeec4 --- /dev/null +++ b/contrib/nitcc/tests/oneliner3.input @@ -0,0 +1,27 @@ + + +if id then id + +if id then + id + if id then id + id +end + +if + id +then + id + if id then id + id +end + +if id then if id then id + +if id then if id then + id + if id then id + id +end + + diff --git a/contrib/nitcc/tests/oneliner3.sablecc b/contrib/nitcc/tests/oneliner3.sablecc new file mode 100644 index 0000000000..b25ac785d0 --- /dev/null +++ b/contrib/nitcc/tests/oneliner3.sablecc @@ -0,0 +1,21 @@ +Grammar oneliner; +Lexer +n = #10; +Parser +Ignored #32; +Occasional n; + +prog + = stmts + ; +expr = 'if' expr 'then' expr + | 'if' expr 'then' eol stmts 'end' + | 'id' + ; + +stmts + = stmts expr eol + | expr eol + ; + +eol = n | ';'; diff --git a/contrib/nitcc/tests/oneliner4.input b/contrib/nitcc/tests/oneliner4.input new file mode 100644 index 0000000000..521cbdeec4 --- /dev/null +++ b/contrib/nitcc/tests/oneliner4.input @@ -0,0 +1,27 @@ + + +if id then id + +if id then + id + if id then id + id +end + +if + id +then + id + if id then id + id +end + +if id then if id then id + +if id then if id then + id + if id then id + id +end + + diff --git a/contrib/nitcc/tests/oneliner4.sablecc b/contrib/nitcc/tests/oneliner4.sablecc new file mode 100644 index 0000000000..2285a6ae64 --- /dev/null +++ b/contrib/nitcc/tests/oneliner4.sablecc @@ -0,0 +1,21 @@ +Grammar oneliner; +Lexer +n = #10; +Parser +Ignored #32; +Occasional n; + +prog + = stmts eol? + ; +expr = 'if' expr 'then' expr + | 'if' expr 'then' eol stmts eol 'end' + | 'id' + ; + +stmts + = stmts eol expr + | expr + ; + +eol = n | ';'; diff --git a/contrib/nitcc/tests/sav/conflict-dangling.1alt1.alt1.input3.res b/contrib/nitcc/tests/sav/conflict-dangling.1alt1.alt1.input3.res index 4bef560b9d..70e85ab200 100644 --- a/contrib/nitcc/tests/sav/conflict-dangling.1alt1.alt1.input3.res +++ b/contrib/nitcc/tests/sav/conflict-dangling.1alt1.alt1.input3.res @@ -1,12 +1,10 @@ NParserError@(1:5-1:6)='3' Nodes[Node] - f_0 - e_1 - '1'@(1:1-1:2) - e_2 - '1'@(1:2-1:3) - e_0 - '0'@(1:3-1:4) - x - '2'@(1:4-1:5) + '1'@(1:1-1:2) + e_2 + '1'@(1:2-1:3) + e_0 + '0'@(1:3-1:4) + x + '2'@(1:4-1:5) '3'@(1:5-1:6) diff --git a/contrib/nitcc/tests/sav/conflict-dangling.1alt1.alt2.input3.res b/contrib/nitcc/tests/sav/conflict-dangling.1alt1.alt2.input3.res index 53f382c7ef..d8b486f728 100644 --- a/contrib/nitcc/tests/sav/conflict-dangling.1alt1.alt2.input3.res +++ b/contrib/nitcc/tests/sav/conflict-dangling.1alt1.alt2.input3.res @@ -1,14 +1,11 @@ NParserError@(1:5-1:6)='3' Nodes[Node] - f_0 - e_1 - '1'@(1:1-1:2) - e_1 - '1'@(1:2-1:3) - e_0 - '0'@(1:3-1:4) - y_0 - x - '2'@(1:4-1:5) - y_1 + '1'@(1:1-1:2) + e_1 + '1'@(1:2-1:3) + e_0 + '0'@(1:3-1:4) + y_0 + x + '2'@(1:4-1:5) '3'@(1:5-1:6) diff --git a/contrib/nitcc/tests/sav/conflict-dangling.1alt1.input3.res b/contrib/nitcc/tests/sav/conflict-dangling.1alt1.input3.res index 3b1d9e1485..7b919e06b0 100644 --- a/contrib/nitcc/tests/sav/conflict-dangling.1alt1.input3.res +++ b/contrib/nitcc/tests/sav/conflict-dangling.1alt1.input3.res @@ -1,11 +1,9 @@ NParserError@(1:5-1:6)='3' Nodes[Node] - f_0 - e_1 - '1'@(1:1-1:2) - e_2 - '1'@(1:2-1:3) - e_0 - '0'@(1:3-1:4) - '2'@(1:4-1:5) + '1'@(1:1-1:2) + e_2 + '1'@(1:2-1:3) + e_0 + '0'@(1:3-1:4) + '2'@(1:4-1:5) '3'@(1:5-1:6) diff --git a/contrib/nitcc/tests/sav/conflict-dangling.alt1.input3.res b/contrib/nitcc/tests/sav/conflict-dangling.alt1.input3.res index 54ff314136..929fe50a3f 100644 --- a/contrib/nitcc/tests/sav/conflict-dangling.alt1.input3.res +++ b/contrib/nitcc/tests/sav/conflict-dangling.alt1.input3.res @@ -1,12 +1,10 @@ NLexerError@(1:5-1:5)='3' Nodes[Node] - f - e_1 - '1'@(1:1-1:2) - e_2 - '1'@(1:2-1:3) - e_0 - '0'@(1:3-1:4) - x - '2'@(1:4-1:5) + '1'@(1:1-1:2) + e_2 + '1'@(1:2-1:3) + e_0 + '0'@(1:3-1:4) + x + '2'@(1:4-1:5) NLexerError@(1:5-1:5)='3' diff --git a/contrib/nitcc/tests/sav/conflict-dangling.alt2.input3.res b/contrib/nitcc/tests/sav/conflict-dangling.alt2.input3.res index 8a40795a26..65da091de4 100644 --- a/contrib/nitcc/tests/sav/conflict-dangling.alt2.input3.res +++ b/contrib/nitcc/tests/sav/conflict-dangling.alt2.input3.res @@ -1,14 +1,11 @@ NLexerError@(1:5-1:5)='3' Nodes[Node] - f - e_1 - '1'@(1:1-1:2) - e_1 - '1'@(1:2-1:3) - e_0 - '0'@(1:3-1:4) - y_0 - x - '2'@(1:4-1:5) - y_1 + '1'@(1:1-1:2) + e_1 + '1'@(1:2-1:3) + e_0 + '0'@(1:3-1:4) + y_0 + x + '2'@(1:4-1:5) NLexerError@(1:5-1:5)='3' diff --git a/contrib/nitcc/tests/sav/conflict-dangling.input3.res b/contrib/nitcc/tests/sav/conflict-dangling.input3.res index 5d5f07f02f..b8e5ed10a2 100644 --- a/contrib/nitcc/tests/sav/conflict-dangling.input3.res +++ b/contrib/nitcc/tests/sav/conflict-dangling.input3.res @@ -1,11 +1,9 @@ NLexerError@(1:5-1:5)='3' Nodes[Node] - f - e_1 - '1'@(1:1-1:2) - e_2 - '1'@(1:2-1:3) - e_0 - '0'@(1:3-1:4) - '2'@(1:4-1:5) + '1'@(1:1-1:2) + e_2 + '1'@(1:2-1:3) + e_0 + '0'@(1:3-1:4) + '2'@(1:4-1:5) NLexerError@(1:5-1:5)='3' diff --git a/contrib/nitcc/tests/sav/inf5000-04-lexer-demo.input2.res b/contrib/nitcc/tests/sav/inf5000-04-lexer-demo.input2.res index bc5f6070a5..1a73622660 100644 --- a/contrib/nitcc/tests/sav/inf5000-04-lexer-demo.input2.res +++ b/contrib/nitcc/tests/sav/inf5000-04-lexer-demo.input2.res @@ -1,4 +1,3 @@ NLexerError@(1:1-1:1)='5' Nodes[Node] - p NLexerError@(1:1-1:1)='5' diff --git a/contrib/nitcc/tests/sav/inf5000-05-grammaire-arithmetique.alt1.res b/contrib/nitcc/tests/sav/inf5000-05-grammaire-arithmetique.alt1.res index faf3609077..205ac7f0e0 100644 --- a/contrib/nitcc/tests/sav/inf5000-05-grammaire-arithmetique.alt1.res +++ b/contrib/nitcc/tests/sav/inf5000-05-grammaire-arithmetique.alt1.res @@ -1 +1 @@ -16:1-16:11 Syntax Error: Unexpected unknown_keyword 'Precedence'; is acceptable instead: Eof +16:1-16:11 Syntax Error: Unexpected unknown_keyword 'Precedence'; is acceptable instead: prod diff --git a/contrib/nitcc/tests/sav/inf5000-06-grammaire2-calculatrice.res b/contrib/nitcc/tests/sav/inf5000-06-grammaire2-calculatrice.res index 0ede2409c8..8e508ef45b 100644 --- a/contrib/nitcc/tests/sav/inf5000-06-grammaire2-calculatrice.res +++ b/contrib/nitcc/tests/sav/inf5000-06-grammaire2-calculatrice.res @@ -1 +1 @@ -15:7-15:17 Syntax Error: Unexpected unknown_keyword 'Precedence'; is acceptable instead: Eof +15:7-15:17 Syntax Error: Unexpected unknown_keyword 'Precedence'; is acceptable instead: prod diff --git a/contrib/nitcc/tests/sav/inf5000-06-grammaire2-grammaire.input.res b/contrib/nitcc/tests/sav/inf5000-06-grammaire2-grammaire.input.res index 417bd3ae89..7d424874d9 100644 --- a/contrib/nitcc/tests/sav/inf5000-06-grammaire2-grammaire.input.res +++ b/contrib/nitcc/tests/sav/inf5000-06-grammaire2-grammaire.input.res @@ -92,19 +92,17 @@ Nodes[Node] ';'@(4:27-4:28) id@(5:1-5:6)='atoms' '='@(5:7-5:8) - alts_many - alts_one - alt_0 - altid@(5:9-5:16)='{many:}' + alts_one + alt_0 + altid@(5:9-5:16)='{many:}' + atoms_many atoms_many - atoms_many - atoms_none - atom_id - id@(5:17-5:22)='atoms' + atoms_none atom_id - id@(5:23-5:27)='atom' - '|'@(5:28-5:29) - alt_0 - altid@(5:30-5:37)='{none:}' - atoms_none + id@(5:17-5:22)='atoms' + atom_id + id@(5:23-5:27)='atom' + '|'@(5:28-5:29) + altid@(5:30-5:37)='{none:}' + atoms_none NLexerError@(5:38-5:38)='E' diff --git a/contrib/nitcc/tests/sav/inf5000-06-grammaire2-grammaire2.res b/contrib/nitcc/tests/sav/inf5000-06-grammaire2-grammaire2.res index c344a5103b..3d446b58de 100644 --- a/contrib/nitcc/tests/sav/inf5000-06-grammaire2-grammaire2.res +++ b/contrib/nitcc/tests/sav/inf5000-06-grammaire2-grammaire2.res @@ -1 +1 @@ -11:20-11:29 Syntax Error: Unexpected unknown_keyword 'Separator'; is acceptable instead: elem, text +11:20-11:29 Syntax Error: Unexpected unknown_keyword 'Separator'; is acceptable instead: '*', '?', '+' diff --git a/contrib/nitcc/tests/sav/inf5000-06-grammaire2-instructions.alt3.res b/contrib/nitcc/tests/sav/inf5000-06-grammaire2-instructions.alt3.res index 46710676f3..6ad75b73db 100644 --- a/contrib/nitcc/tests/sav/inf5000-06-grammaire2-instructions.alt3.res +++ b/contrib/nitcc/tests/sav/inf5000-06-grammaire2-instructions.alt3.res @@ -1 +1 @@ -20:14-20:23 Syntax Error: Unexpected unknown_keyword 'Separator'; is acceptable instead: elem, text +20:14-20:23 Syntax Error: Unexpected unknown_keyword 'Separator'; is acceptable instead: '*', '?', '+' diff --git a/contrib/nitcc/tests/sav/inf5000-06-grammaire2-polygone.res b/contrib/nitcc/tests/sav/inf5000-06-grammaire2-polygone.res index 0f93b1b841..4137e255c5 100644 --- a/contrib/nitcc/tests/sav/inf5000-06-grammaire2-polygone.res +++ b/contrib/nitcc/tests/sav/inf5000-06-grammaire2-polygone.res @@ -1 +1 @@ -8:25-8:34 Syntax Error: Unexpected unknown_keyword 'Separator'; is acceptable instead: elem, text +8:25-8:34 Syntax Error: Unexpected unknown_keyword 'Separator'; is acceptable instead: '*', '?', '+' diff --git a/contrib/nitcc/tests/sav/lexer-c-comment.alt3.res b/contrib/nitcc/tests/sav/lexer-c-comment.alt3.res index c55cc90f02..92dc53783f 100644 --- a/contrib/nitcc/tests/sav/lexer-c-comment.alt3.res +++ b/contrib/nitcc/tests/sav/lexer-c-comment.alt3.res @@ -1 +1 @@ -11:26-11:35 Syntax Error: Unexpected unknown_keyword 'Lookahead'; is acceptable instead: ')', '|' +11:26-11:35 Syntax Error: Unexpected unknown_keyword 'Lookahead'; is acceptable instead: '.' diff --git a/contrib/nitcc/tests/sav/lexer-errors.alt7.res b/contrib/nitcc/tests/sav/lexer-errors.alt7.res index c45c7294f9..4830a59c05 100644 --- a/contrib/nitcc/tests/sav/lexer-errors.alt7.res +++ b/contrib/nitcc/tests/sav/lexer-errors.alt7.res @@ -1 +1 @@ -10:16-10:25 Syntax Error: Unexpected unknown_keyword 'Lookahead'; is acceptable instead: ';', '|' +10:16-10:25 Syntax Error: Unexpected unknown_keyword 'Lookahead'; is acceptable instead: '.' diff --git a/contrib/nitcc/tests/sav/lexer-implicit-longest-and-priority.alt1.res b/contrib/nitcc/tests/sav/lexer-implicit-longest-and-priority.alt1.res index 9f9fd495fa..09391220fa 100644 --- a/contrib/nitcc/tests/sav/lexer-implicit-longest-and-priority.alt1.res +++ b/contrib/nitcc/tests/sav/lexer-implicit-longest-and-priority.alt1.res @@ -1 +1 @@ -4:9-4:18 Syntax Error: Unexpected unknown_keyword 'Lookahead'; is acceptable instead: ';', '|' +4:9-4:18 Syntax Error: Unexpected unknown_keyword 'Lookahead'; is acceptable instead: '.' diff --git a/contrib/nitcc/tests/sav/lexer-implicit-longest-and-priority.res b/contrib/nitcc/tests/sav/lexer-implicit-longest-and-priority.res index 9f9fd495fa..09391220fa 100644 --- a/contrib/nitcc/tests/sav/lexer-implicit-longest-and-priority.res +++ b/contrib/nitcc/tests/sav/lexer-implicit-longest-and-priority.res @@ -1 +1 @@ -4:9-4:18 Syntax Error: Unexpected unknown_keyword 'Lookahead'; is acceptable instead: ';', '|' +4:9-4:18 Syntax Error: Unexpected unknown_keyword 'Lookahead'; is acceptable instead: '.' diff --git a/contrib/nitcc/tests/sav/lexer-implicit-longest.alt1.res b/contrib/nitcc/tests/sav/lexer-implicit-longest.alt1.res index 4d18e58c11..784ee61bdf 100644 --- a/contrib/nitcc/tests/sav/lexer-implicit-longest.alt1.res +++ b/contrib/nitcc/tests/sav/lexer-implicit-longest.alt1.res @@ -1 +1 @@ -3:10-3:19 Syntax Error: Unexpected unknown_keyword 'Lookahead'; is acceptable instead: ';', '|' +3:10-3:19 Syntax Error: Unexpected unknown_keyword 'Lookahead'; is acceptable instead: '.' diff --git a/contrib/nitcc/tests/sav/lexer-implicit-longest.res b/contrib/nitcc/tests/sav/lexer-implicit-longest.res index 1d461d0ba9..b816a063fa 100644 --- a/contrib/nitcc/tests/sav/lexer-implicit-longest.res +++ b/contrib/nitcc/tests/sav/lexer-implicit-longest.res @@ -1 +1 @@ -3:9-3:18 Syntax Error: Unexpected unknown_keyword 'Lookahead'; is acceptable instead: ';', '|' +3:9-3:18 Syntax Error: Unexpected unknown_keyword 'Lookahead'; is acceptable instead: '.' diff --git a/contrib/nitcc/tests/sav/lexer-precedences.alt8.res b/contrib/nitcc/tests/sav/lexer-precedences.alt8.res index e445b4ef22..adf909da03 100644 --- a/contrib/nitcc/tests/sav/lexer-precedences.alt8.res +++ b/contrib/nitcc/tests/sav/lexer-precedences.alt8.res @@ -1 +1 @@ -6:18-6:27 Syntax Error: Unexpected unknown_keyword 'Lookahead'; is acceptable instead: ')', '|' +6:18-6:27 Syntax Error: Unexpected unknown_keyword 'Lookahead'; is acceptable instead: '.' diff --git a/contrib/nitcc/tests/sav/occasional.input.res b/contrib/nitcc/tests/sav/occasional.input.res new file mode 100644 index 0000000000..fb23facf78 --- /dev/null +++ b/contrib/nitcc/tests/sav/occasional.input.res @@ -0,0 +1,16 @@ +Start + s_0 + s_0 + s_0 + s_1 + e_0 + 'a'@(1:1-1:2) + 'a'@(1:4-1:5) + e_1 + 'b'@(1:5-1:6) + e_1 + 'b'@(1:6-1:7) + e_0 + 'a'@(1:7-1:8) + 'a'@(1:8-1:9) + Eof@(2:1-2:1)='' diff --git a/contrib/nitcc/tests/sav/occasional2.input.res b/contrib/nitcc/tests/sav/occasional2.input.res new file mode 100644 index 0000000000..562f7743ca --- /dev/null +++ b/contrib/nitcc/tests/sav/occasional2.input.res @@ -0,0 +1,18 @@ +Start + s_0 + s_0 + s_0 + s_1 + e_0 + 'a'@(1:1-1:2) + 'a'@(1:4-1:5) + e_1 + b + 'b'@(1:5-1:6) + e_1 + b + 'b'@(1:6-1:7) + e_0 + 'a'@(1:7-1:8) + 'a'@(1:8-1:9) + Eof@(2:1-2:1)='' diff --git a/contrib/nitcc/tests/sav/oneliner.input.res b/contrib/nitcc/tests/sav/oneliner.input.res index 83d628a8d3..749ddd547f 100644 --- a/contrib/nitcc/tests/sav/oneliner.input.res +++ b/contrib/nitcc/tests/sav/oneliner.input.res @@ -72,7 +72,6 @@ Nodes[Node] stmt_2 'id'@(4:23-4:25) 'end'@(4:26-4:29) - n - Nodes[Neol] - eol@(4:29-5:1)='\n' + Nodes[Neol] + eol@(4:29-5:1)='\n' Eof@(5:1-5:1)='' diff --git a/contrib/nitcc/tests/sav/oneliner3.input.res b/contrib/nitcc/tests/sav/oneliner3.input.res new file mode 100644 index 0000000000..db71cb0ba3 --- /dev/null +++ b/contrib/nitcc/tests/sav/oneliner3.input.res @@ -0,0 +1,126 @@ +Start + prog + stmts_0 + stmts_0 + stmts_0 + stmts_0 + stmts_1 + expr_0 + 'if'@(3:1-3:3) + expr_2 + 'id'@(3:4-3:6) + 'then'@(3:7-3:11) + expr_2 + 'id'@(3:12-3:14) + eol_0 + n@(3:14-4:1)='\n' + expr_1 + 'if'@(5:1-5:3) + expr_2 + 'id'@(5:4-5:6) + 'then'@(5:7-5:11) + eol_0 + n@(5:11-6:1)='\n' + stmts_0 + stmts_0 + stmts_1 + expr_2 + 'id'@(6:3-6:5) + eol_0 + n@(6:5-7:1)='\n' + expr_0 + 'if'@(7:3-7:5) + expr_2 + 'id'@(7:6-7:8) + 'then'@(7:9-7:13) + expr_2 + 'id'@(7:14-7:16) + eol_0 + n@(7:16-8:1)='\n' + expr_2 + 'id'@(8:3-8:5) + eol_0 + n@(8:5-9:1)='\n' + 'end'@(9:1-9:4) + eol_0 + n@(9:4-10:1)='\n' + expr_1 + 'if'@(11:1-11:3) + expr_2 + 'id'@(12:3-12:5) + 'then'@(13:1-13:5) + eol_0 + n@(13:5-14:1)='\n' + stmts_0 + stmts_0 + stmts_1 + expr_2 + 'id'@(14:3-14:5) + eol_0 + n@(14:5-15:1)='\n' + expr_0 + 'if'@(15:3-15:5) + expr_2 + 'id'@(15:6-15:8) + 'then'@(15:9-15:13) + expr_2 + 'id'@(15:14-15:16) + eol_0 + n@(15:16-16:1)='\n' + expr_2 + 'id'@(16:3-16:5) + eol_0 + n@(16:5-17:1)='\n' + 'end'@(17:1-17:4) + eol_0 + n@(17:4-18:1)='\n' + expr_0 + 'if'@(19:1-19:3) + expr_2 + 'id'@(19:4-19:6) + 'then'@(19:7-19:11) + expr_0 + 'if'@(19:12-19:14) + expr_2 + 'id'@(19:15-19:17) + 'then'@(19:18-19:22) + expr_2 + 'id'@(19:23-19:25) + eol_0 + n@(19:25-20:1)='\n' + expr_0 + 'if'@(21:1-21:3) + expr_2 + 'id'@(21:4-21:6) + 'then'@(21:7-21:11) + expr_1 + 'if'@(21:12-21:14) + expr_2 + 'id'@(21:15-21:17) + 'then'@(21:18-21:22) + eol_0 + n@(21:22-22:1)='\n' + stmts_0 + stmts_0 + stmts_1 + expr_2 + 'id'@(22:3-22:5) + eol_0 + n@(22:5-23:1)='\n' + expr_0 + 'if'@(23:3-23:5) + expr_2 + 'id'@(23:6-23:8) + 'then'@(23:9-23:13) + expr_2 + 'id'@(23:14-23:16) + eol_0 + n@(23:16-24:1)='\n' + expr_2 + 'id'@(24:3-24:5) + eol_0 + n@(24:5-25:1)='\n' + 'end'@(25:1-25:4) + eol_0 + n@(25:4-26:1)='\n' + Eof@(28:1-28:1)='' diff --git a/contrib/nitcc/tests/sav/oneliner4.input.res b/contrib/nitcc/tests/sav/oneliner4.input.res new file mode 100644 index 0000000000..bd2c474ff8 --- /dev/null +++ b/contrib/nitcc/tests/sav/oneliner4.input.res @@ -0,0 +1,126 @@ +Start + prog + stmts_0 + stmts_0 + stmts_0 + stmts_0 + stmts_1 + expr_0 + 'if'@(3:1-3:3) + expr_2 + 'id'@(3:4-3:6) + 'then'@(3:7-3:11) + expr_2 + 'id'@(3:12-3:14) + eol_0 + n@(3:14-4:1)='\n' + expr_1 + 'if'@(5:1-5:3) + expr_2 + 'id'@(5:4-5:6) + 'then'@(5:7-5:11) + eol_0 + n@(5:11-6:1)='\n' + stmts_0 + stmts_0 + stmts_1 + expr_2 + 'id'@(6:3-6:5) + eol_0 + n@(6:5-7:1)='\n' + expr_0 + 'if'@(7:3-7:5) + expr_2 + 'id'@(7:6-7:8) + 'then'@(7:9-7:13) + expr_2 + 'id'@(7:14-7:16) + eol_0 + n@(7:16-8:1)='\n' + expr_2 + 'id'@(8:3-8:5) + eol_0 + n@(8:5-9:1)='\n' + 'end'@(9:1-9:4) + eol_0 + n@(9:4-10:1)='\n' + expr_1 + 'if'@(11:1-11:3) + expr_2 + 'id'@(12:3-12:5) + 'then'@(13:1-13:5) + eol_0 + n@(13:5-14:1)='\n' + stmts_0 + stmts_0 + stmts_1 + expr_2 + 'id'@(14:3-14:5) + eol_0 + n@(14:5-15:1)='\n' + expr_0 + 'if'@(15:3-15:5) + expr_2 + 'id'@(15:6-15:8) + 'then'@(15:9-15:13) + expr_2 + 'id'@(15:14-15:16) + eol_0 + n@(15:16-16:1)='\n' + expr_2 + 'id'@(16:3-16:5) + eol_0 + n@(16:5-17:1)='\n' + 'end'@(17:1-17:4) + eol_0 + n@(17:4-18:1)='\n' + expr_0 + 'if'@(19:1-19:3) + expr_2 + 'id'@(19:4-19:6) + 'then'@(19:7-19:11) + expr_0 + 'if'@(19:12-19:14) + expr_2 + 'id'@(19:15-19:17) + 'then'@(19:18-19:22) + expr_2 + 'id'@(19:23-19:25) + eol_0 + n@(19:25-20:1)='\n' + expr_0 + 'if'@(21:1-21:3) + expr_2 + 'id'@(21:4-21:6) + 'then'@(21:7-21:11) + expr_1 + 'if'@(21:12-21:14) + expr_2 + 'id'@(21:15-21:17) + 'then'@(21:18-21:22) + eol_0 + n@(21:22-22:1)='\n' + stmts_0 + stmts_0 + stmts_1 + expr_2 + 'id'@(22:3-22:5) + eol_0 + n@(22:5-23:1)='\n' + expr_0 + 'if'@(23:3-23:5) + expr_2 + 'id'@(23:6-23:8) + 'then'@(23:9-23:13) + expr_2 + 'id'@(23:14-23:16) + eol_0 + n@(23:16-24:1)='\n' + expr_2 + 'id'@(24:3-24:5) + eol_0 + n@(24:5-25:1)='\n' + 'end'@(25:1-25:4) + eol_0 + n@(25:4-26:1)='\n' + Eof@(28:1-28:1)='' diff --git a/contrib/nitcc/tests/sav/parser-plusize.input.res b/contrib/nitcc/tests/sav/parser-plusize.input.res index 2e4eab4721..f789317f0c 100644 --- a/contrib/nitcc/tests/sav/parser-plusize.input.res +++ b/contrib/nitcc/tests/sav/parser-plusize.input.res @@ -2,27 +2,25 @@ NParserError@(3:5-3:6)='b' Nodes[Node] s_0 s_0 - s_0 - s_1 - 's'@(1:1-1:2) - t - Nodes[Nab] - ab - 'a'@(1:3-1:4) - 'b'@(1:4-1:5) - 's'@(2:1-2:2) + s_1 + 's'@(1:1-1:2) t Nodes[Nab] ab - 'a'@(2:3-2:4) - 'b'@(2:4-2:5) - ab - 'a'@(2:5-2:6) - 'b'@(2:6-2:7) - 's'@(3:1-3:2) + 'a'@(1:3-1:4) + 'b'@(1:4-1:5) + 's'@(2:1-2:2) t Nodes[Nab] ab - 'a'@(3:3-3:4) - 'b'@(3:4-3:5) + 'a'@(2:3-2:4) + 'b'@(2:4-2:5) + ab + 'a'@(2:5-2:6) + 'b'@(2:6-2:7) + 's'@(3:1-3:2) + Nodes[Nab] + ab + 'a'@(3:3-3:4) + 'b'@(3:4-3:5) 'b'@(3:5-3:6)