forked from zaach/jison
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding JISON test cases as provided by zaach/jison-lex#23 (with a min…
…or tweak to test/showcase `e + e` action code expansion with named variables: `$e1 + $e2` instead of the more cryptic (old-skool yacc style action code) `$1 + $3`
- Loading branch information
1 parent
5cb5cd4
commit 2c2f82c
Showing
2 changed files
with
66 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// title: Parse error when using arrow function in rules | ||
// | ||
// ... | ||
// | ||
// This is the SUCCESSFUL lexer spec | ||
// | ||
|
||
let grammar = { | ||
lex: { | ||
rules: [ | ||
['\\s+', ''], | ||
['\\d+', function () { return 'NUMBER'}], | ||
['\\+', function () { return '+' }], | ||
['$', function () { return 'EOF' }], | ||
] | ||
}, | ||
operators: [ | ||
['left', '+'] | ||
], | ||
bnf: { | ||
'es': [ | ||
['e EOF', 'return $1'] | ||
], | ||
'e': [ | ||
['e + e', '$$ = $e1 + $e2'], | ||
['NUMBER', '$$ = Number(yytext)'] | ||
] | ||
} | ||
}; | ||
|
||
module.exports = grammar; | ||
// export default grammar; | ||
|
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,33 @@ | ||
// title: Parse error when using arrow function in rules | ||
// | ||
// ... | ||
// | ||
// This is the FAILING lexer spec | ||
// | ||
|
||
let grammar = { | ||
lex: { | ||
rules: [ | ||
['\\s+', ''], | ||
['\\d+', () => 'NUMBER'], | ||
['\\+', () => '+'], | ||
['$', () => 'EOF'], | ||
] | ||
}, | ||
operators: [ | ||
['left', '+'] | ||
], | ||
bnf: { | ||
'es': [ | ||
['e EOF', 'return $1'] | ||
], | ||
'e': [ | ||
['e + e', '$$ = $e1 + $e2'], | ||
['NUMBER', '$$ = Number(yytext)'] | ||
] | ||
} | ||
}; | ||
|
||
module.exports = grammar; | ||
// export default grammar; | ||
|