Allow conflicts involving repeat rules to be whitelisted, via their parent rule
This commit is contained in:
parent
119c67dd78
commit
84e4114f79
4 changed files with 119 additions and 9 deletions
14
test/fixtures/test_grammars/conflict_in_repeat_rule/expected_error.txt
vendored
Normal file
14
test/fixtures/test_grammars/conflict_in_repeat_rule/expected_error.txt
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
Unresolved conflict for symbol sequence:
|
||||
|
||||
'[' identifier • ']' …
|
||||
|
||||
Possible interpretations:
|
||||
|
||||
1: '[' (array_repeat1 identifier) • ']' …
|
||||
2: '[' (array_type_repeat1 identifier) • ']' …
|
||||
|
||||
Possible resolutions:
|
||||
|
||||
1: Specify a higher precedence in `array_repeat1` than in the other rules.
|
||||
2: Specify a higher precedence in `array_type_repeat1` than in the other rules.
|
||||
3: Add a conflict for these rules: `array` `array_type`
|
||||
76
test/fixtures/test_grammars/conflict_in_repeat_rule/grammar.json
vendored
Normal file
76
test/fixtures/test_grammars/conflict_in_repeat_rule/grammar.json
vendored
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
{
|
||||
"name": "conflict_in_repeat_rule",
|
||||
|
||||
"rules": {
|
||||
"statement": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{"type": "SYMBOL", "name": "array"},
|
||||
{"type": "STRING", "value": ";"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{"type": "SYMBOL", "name": "array_type"},
|
||||
{"type": "SYMBOL", "name": "identifier"},
|
||||
{"type": "STRING", "value": ";"}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
"array": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "["
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{"type": "SYMBOL", "name": "identifier"},
|
||||
{"type": "STRING", "value": "0"}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "]"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
"array_type": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "["
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{"type": "SYMBOL", "name": "identifier"},
|
||||
{"type": "STRING", "value": "void"}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "]"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
"identifier": {"type": "PATTERN", "value": "\\a+"}
|
||||
}
|
||||
}
|
||||
1
test/fixtures/test_grammars/conflict_in_repeat_rule/readme.md
vendored
Normal file
1
test/fixtures/test_grammars/conflict_in_repeat_rule/readme.md
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
This grammar has a conflict that involves *repeat rules*: auxiliary rules that are added by the parser generator in order to implement repetition. There is no way of referring to these rules in the grammar DSL, so these conflicts must be resolved by referring to their parent rules.
|
||||
Loading…
Add table
Add a link
Reference in a new issue