Add string literals
Once again, taking the rules more or less straight from tree-sitter-go.
This commit is contained in:
parent
57b38c01c0
commit
f548b1d5ad
5 changed files with 712 additions and 181 deletions
106
src/grammar.json
generated
106
src/grammar.json
generated
|
|
@ -78,6 +78,10 @@
|
|||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "integer_literal"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_string_literal"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
@ -105,6 +109,108 @@
|
|||
"value": "[0-9]+"
|
||||
}
|
||||
]
|
||||
},
|
||||
"_string_literal": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "raw_string_literal"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "interpreted_string_literal"
|
||||
}
|
||||
]
|
||||
},
|
||||
"raw_string_literal": {
|
||||
"type": "TOKEN",
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "`"
|
||||
},
|
||||
{
|
||||
"type": "PATTERN",
|
||||
"value": "[^`]+"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "`"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"interpreted_string_literal": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "\""
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "PATTERN",
|
||||
"value": "[^\"\\n\\\\]+"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "escape_sequence"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "IMMEDIATE_TOKEN",
|
||||
"content": {
|
||||
"type": "STRING",
|
||||
"value": "\""
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"escape_sequence": {
|
||||
"type": "IMMEDIATE_TOKEN",
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "\\"
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "PATTERN",
|
||||
"value": "[^xuU]"
|
||||
},
|
||||
{
|
||||
"type": "PATTERN",
|
||||
"value": "\\d{2,3}"
|
||||
},
|
||||
{
|
||||
"type": "PATTERN",
|
||||
"value": "x[0-9a-fA-F]{2,}"
|
||||
},
|
||||
{
|
||||
"type": "PATTERN",
|
||||
"value": "u[0-9a-fA-F]{4}"
|
||||
},
|
||||
{
|
||||
"type": "PATTERN",
|
||||
"value": "U[0-9a-fA-F]{8}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"extras": [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue