Add test for handling of precedence within tokens
This commit is contained in:
parent
9c9149ac45
commit
23e4596ec1
3 changed files with 83 additions and 2 deletions
22
test/fixtures/test_grammars/precedence_on_token/corpus.txt
vendored
Normal file
22
test/fixtures/test_grammars/precedence_on_token/corpus.txt
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
==========================================
|
||||
simple strings
|
||||
==========================================
|
||||
|
||||
"hi"
|
||||
|
||||
---
|
||||
|
||||
(program (string))
|
||||
|
||||
==========================================
|
||||
strings starting with double slashes
|
||||
==========================================
|
||||
|
||||
// comment
|
||||
"//not \t a \t comment"
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(comment)
|
||||
(string (escape_sequence) (escape_sequence)))
|
||||
61
test/fixtures/test_grammars/precedence_on_token/grammar.json
vendored
Normal file
61
test/fixtures/test_grammars/precedence_on_token/grammar.json
vendored
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
{
|
||||
"name": "precedence_on_token",
|
||||
|
||||
"extras": [
|
||||
{"type": "SYMBOL", "name": "comment"},
|
||||
{"type": "PATTERN", "value": "\\s"},
|
||||
],
|
||||
|
||||
"rules": {
|
||||
"program": {
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "string"
|
||||
}
|
||||
},
|
||||
|
||||
"comment": {
|
||||
"type": "PATTERN",
|
||||
"value": "//.*"
|
||||
},
|
||||
|
||||
"string": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{"type": "STRING", "value": "\""},
|
||||
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "TOKEN",
|
||||
"content": {
|
||||
"type": "PREC",
|
||||
"value": 1,
|
||||
"content": {
|
||||
"type": "PATTERN",
|
||||
"value": "[^\"\n\\\\]+"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "escape_sequence"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
{"type": "STRING", "value": "\""}
|
||||
]
|
||||
},
|
||||
|
||||
"escape_sequence": {
|
||||
"type": "PATTERN",
|
||||
"value": "\\\\."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -9,8 +9,6 @@
|
|||
|
||||
START_TEST
|
||||
|
||||
if (TREE_SITTER_SEED == -1) return;
|
||||
|
||||
string grammars_dir_path = join_path({"test", "fixtures", "test_grammars"});
|
||||
vector<string> test_languages = list_directory(grammars_dir_path);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue