handle quoted template expressions and template interpolations
This commit is contained in:
197
src/grammar.json
197
src/grammar.json
@@ -152,6 +152,10 @@
|
||||
"type": "SYMBOL",
|
||||
"name": "literal_value"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "template_expr"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "collection_value"
|
||||
@@ -233,10 +237,6 @@
|
||||
"type": "SYMBOL",
|
||||
"name": "numeric_lit"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "string_lit"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "bool_lit"
|
||||
@@ -251,87 +251,6 @@
|
||||
"type": "PATTERN",
|
||||
"value": "[0-9]+(\\.[0-9]+([eE][-+]?[0-9]+)?)?"
|
||||
},
|
||||
"string_lit": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "\""
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "IMMEDIATE_TOKEN",
|
||||
"content": {
|
||||
"type": "PREC",
|
||||
"value": 1,
|
||||
"content": {
|
||||
"type": "PATTERN",
|
||||
"value": "[^\\\\\"\\n\\r\\t]+"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "escape_sequence"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "\""
|
||||
}
|
||||
]
|
||||
},
|
||||
"escape_sequence": {
|
||||
"type": "IMMEDIATE_TOKEN",
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "\\"
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "\\"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "\""
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "n"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "r"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "t"
|
||||
},
|
||||
{
|
||||
"type": "PATTERN",
|
||||
"value": "u[0-9a-fA-F]{4}"
|
||||
},
|
||||
{
|
||||
"type": "PATTERN",
|
||||
"value": "U[0-9a-fA-F]{8}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"bool_lit": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
@@ -1086,6 +1005,99 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"template_expr": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "quoted_template"
|
||||
}
|
||||
]
|
||||
},
|
||||
"string_lit": {
|
||||
"type": "SYMBOL",
|
||||
"name": "quoted_template"
|
||||
},
|
||||
"quoted_template": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "\""
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_template_char"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "escape_sequence"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "template_interpolation"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "\""
|
||||
}
|
||||
]
|
||||
},
|
||||
"template_interpolation": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "${"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "${~"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_template_char_in_interpolation"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "escape_sequence"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "}"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "~}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"comment": {
|
||||
"type": "TOKEN",
|
||||
"content": {
|
||||
@@ -1167,7 +1179,20 @@
|
||||
]
|
||||
],
|
||||
"precedences": [],
|
||||
"externals": [],
|
||||
"externals": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_template_char"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_template_char_in_interpolation"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "escape_sequence"
|
||||
}
|
||||
],
|
||||
"inline": [],
|
||||
"supertypes": []
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user