Fix handling of token rules directly inside of alias, prec, or field.
Fixes #483
This commit is contained in:
parent
b4a2f4ed60
commit
660efd8c0f
4 changed files with 72 additions and 1 deletions
|
|
@ -366,7 +366,7 @@ impl FromIterator<Symbol> for TokenSet {
|
|||
|
||||
fn add_metadata<T: FnOnce(&mut MetadataParams)>(input: Rule, f: T) -> Rule {
|
||||
match input {
|
||||
Rule::Metadata { rule, mut params } => {
|
||||
Rule::Metadata { rule, mut params } if !params.is_token => {
|
||||
f(&mut params);
|
||||
Rule::Metadata { rule, params }
|
||||
}
|
||||
|
|
|
|||
9
test/fixtures/test_grammars/aliased_token_rules/corpus.txt
vendored
Normal file
9
test/fixtures/test_grammars/aliased_token_rules/corpus.txt
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
======================
|
||||
Aliased token rules
|
||||
======================
|
||||
|
||||
abcde
|
||||
|
||||
---
|
||||
|
||||
(expression (X) (Y))
|
||||
61
test/fixtures/test_grammars/aliased_token_rules/grammar.json
vendored
Normal file
61
test/fixtures/test_grammars/aliased_token_rules/grammar.json
vendored
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
{
|
||||
"name": "aliased_token_rules",
|
||||
|
||||
"extras": [
|
||||
{"type": "PATTERN", "value": "\\s"}
|
||||
],
|
||||
|
||||
"rules": {
|
||||
"expression": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"type": "ALIAS",
|
||||
"value": "X",
|
||||
"named": true,
|
||||
"content": {
|
||||
"type": "TOKEN",
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "c"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "ALIAS",
|
||||
"value": "Y",
|
||||
"named": true,
|
||||
"content": {
|
||||
"type": "IMMEDIATE_TOKEN",
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "d"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "e"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
1
test/fixtures/test_grammars/aliased_token_rules/readme.md
vendored
Normal file
1
test/fixtures/test_grammars/aliased_token_rules/readme.md
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
This grammar shows that `ALIAS` rules can be applied directly to `TOKEN` and `IMMEDIATE_TOKEN` rules.
|
||||
Loading…
Add table
Add a link
Reference in a new issue