Allow non-terminal extras
This commit is contained in:
parent
49c632ae90
commit
fcaabea0cf
8 changed files with 274 additions and 83 deletions
22
test/fixtures/test_grammars/extra_non_terminals/corpus.txt
vendored
Normal file
22
test/fixtures/test_grammars/extra_non_terminals/corpus.txt
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
==============
|
||||
No extras
|
||||
==============
|
||||
|
||||
a b c d
|
||||
|
||||
---
|
||||
|
||||
(module)
|
||||
|
||||
==============
|
||||
Extras
|
||||
==============
|
||||
|
||||
a (one) b (two) (three) c d
|
||||
|
||||
---
|
||||
|
||||
(module
|
||||
(comment)
|
||||
(comment)
|
||||
(comment))
|
||||
35
test/fixtures/test_grammars/extra_non_terminals/grammar.json
vendored
Normal file
35
test/fixtures/test_grammars/extra_non_terminals/grammar.json
vendored
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
"name": "extra_non_terminals",
|
||||
|
||||
"extras": [
|
||||
{"type": "PATTERN", "value": "\\s"},
|
||||
{"type": "SYMBOL", "name": "comment"}
|
||||
],
|
||||
|
||||
"rules": {
|
||||
"module": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{"type": "STRING", "value": "a"},
|
||||
{"type": "STRING", "value": "b"},
|
||||
{"type": "STRING", "value": "c"},
|
||||
{"type": "STRING", "value": "d"}
|
||||
]
|
||||
},
|
||||
|
||||
"comment": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{"type": "STRING", "value": "("},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "PATTERN",
|
||||
"value": "[a-z]+"
|
||||
}
|
||||
},
|
||||
{"type": "STRING", "value": ")"}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue