-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce the keyword `Occasional` that make token be ignored instead of producing syntax errors. This makes it easier to parse some language where spaces and/or new lines are sometime meaningful but not always.
- Loading branch information
Showing
38 changed files
with
515 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
abbabbaa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Parser | ||
Ignored #10, #32; | ||
Occasional 'b'; | ||
s = s e | e; | ||
e = 'a' 'a' | 'b' ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
abbabbaa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Parser | ||
Ignored #10, #32; | ||
Occasional 'b'; | ||
s = s e | e; | ||
e = 'a' 'a' | b ; | ||
b = 'b' ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ';'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ';'; |
16 changes: 7 additions & 9 deletions
16
contrib/nitcc/tests/sav/conflict-dangling.1alt1.alt1.input3.res
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
19 changes: 8 additions & 11 deletions
19
contrib/nitcc/tests/sav/conflict-dangling.1alt1.alt2.input3.res
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
NLexerError@(1:1-1:1)='5' | ||
Nodes[Node] | ||
p | ||
NLexerError@(1:1-1:1)='5' |
2 changes: 1 addition & 1 deletion
2
contrib/nitcc/tests/sav/inf5000-05-grammaire-arithmetique.alt1.res
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: '*', '?', '+' |
2 changes: 1 addition & 1 deletion
2
contrib/nitcc/tests/sav/inf5000-06-grammaire2-instructions.alt3.res
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: '*', '?', '+' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: '*', '?', '+' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: '.' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: '.' |
2 changes: 1 addition & 1 deletion
2
contrib/nitcc/tests/sav/lexer-implicit-longest-and-priority.alt1.res
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: '.' |
Oops, something went wrong.