simplify whitespace handling; support hexadecimal numeric literals; allow empty configs
This commit is contained in:
598
src/grammar.json
598
src/grammar.json
@@ -2,136 +2,51 @@
|
||||
"name": "hcl",
|
||||
"rules": {
|
||||
"config_file": {
|
||||
"type": "SYMBOL",
|
||||
"name": "body"
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "body"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
},
|
||||
"body": {
|
||||
"type": "REPEAT1",
|
||||
"content": {
|
||||
"type": "PREC_LEFT",
|
||||
"value": 0,
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "attribute"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "block"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "one_line_block"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_newlines"
|
||||
}
|
||||
]
|
||||
}
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "attribute"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "block"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"attribute": {
|
||||
"type": "PREC_LEFT",
|
||||
"value": 0,
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "="
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "expression"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_newlines"
|
||||
}
|
||||
]
|
||||
}
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "="
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "expression"
|
||||
}
|
||||
]
|
||||
},
|
||||
"block": {
|
||||
"type": "PREC_LEFT",
|
||||
"value": 0,
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "string_lit"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_block_start"
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_newlines"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "body"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_block_end"
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_newlines"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"one_line_block": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
@@ -162,21 +77,8 @@
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "="
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "expression"
|
||||
}
|
||||
]
|
||||
"type": "SYMBOL",
|
||||
"name": "body"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
@@ -186,10 +88,6 @@
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_block_end"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_newlines"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -207,8 +105,17 @@
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "PATTERN",
|
||||
"value": "\\p{L}"
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "PATTERN",
|
||||
"value": "\\p{L}"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "_"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
@@ -234,17 +141,21 @@
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_expr_term"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "conditional"
|
||||
}
|
||||
]
|
||||
"type": "PREC_RIGHT",
|
||||
"value": 0,
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_expr_term"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "conditional"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"_expr_term": {
|
||||
"type": "CHOICE",
|
||||
@@ -357,8 +268,17 @@
|
||||
]
|
||||
},
|
||||
"numeric_lit": {
|
||||
"type": "PATTERN",
|
||||
"value": "[0-9]+(\\.[0-9]+([eE][-+]?[0-9]+)?)?"
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "PATTERN",
|
||||
"value": "[0-9]+(\\.[0-9]+([eE][-+]?[0-9]+)?)?"
|
||||
},
|
||||
{
|
||||
"type": "PATTERN",
|
||||
"value": "0x[0-9a-zA-Z]+"
|
||||
}
|
||||
]
|
||||
},
|
||||
"bool_lit": {
|
||||
"type": "CHOICE",
|
||||
@@ -430,18 +350,6 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_newlines"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_tuple_end"
|
||||
@@ -457,81 +365,41 @@
|
||||
"value": "]"
|
||||
},
|
||||
"_tuple_elems": {
|
||||
"type": "PREC_RIGHT",
|
||||
"value": 0,
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_newlines"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "expression"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_comma"
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_newlines"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "expression"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "expression"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_comma"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_newlines"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
"name": "expression"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_comma"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"object": {
|
||||
"type": "SEQ",
|
||||
@@ -552,18 +420,6 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_newlines"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_object_end"
|
||||
@@ -579,91 +435,49 @@
|
||||
"value": "}"
|
||||
},
|
||||
"_object_elems": {
|
||||
"type": "PREC_RIGHT",
|
||||
"value": 0,
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "object_elem"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_newlines"
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_comma"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "object_elem"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_comma"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_newlines"
|
||||
},
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_comma"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_newlines"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "object_elem"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_comma"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_newlines"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
"name": "object_elem"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_comma"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"object_elem": {
|
||||
"type": "SEQ",
|
||||
@@ -829,18 +643,6 @@
|
||||
"type": "SYMBOL",
|
||||
"name": "_tuple_start"
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_newlines"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "for_intro"
|
||||
@@ -861,18 +663,6 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_newlines"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_tuple_end"
|
||||
@@ -886,18 +676,6 @@
|
||||
"type": "SYMBOL",
|
||||
"name": "_object_start"
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_newlines"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "for_intro"
|
||||
@@ -938,18 +716,6 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_newlines"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_object_end"
|
||||
@@ -1016,8 +782,12 @@
|
||||
]
|
||||
},
|
||||
"variable_expr": {
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
"type": "PREC_RIGHT",
|
||||
"value": 0,
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
}
|
||||
},
|
||||
"function_call": {
|
||||
"type": "SEQ",
|
||||
@@ -1042,18 +812,6 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_newlines"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_function_call_end"
|
||||
@@ -1074,18 +832,6 @@
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_newline"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "expression"
|
||||
@@ -1096,20 +842,8 @@
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ","
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_newline"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
"type": "SYMBOL",
|
||||
"name": "_comma"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
@@ -1118,18 +852,6 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_newline"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
@@ -1520,17 +1242,6 @@
|
||||
"type": "CHOICE",
|
||||
"members": []
|
||||
},
|
||||
"_newlines": {
|
||||
"type": "PREC_RIGHT",
|
||||
"value": 0,
|
||||
"content": {
|
||||
"type": "REPEAT1",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "_newline"
|
||||
}
|
||||
}
|
||||
},
|
||||
"comment": {
|
||||
"type": "TOKEN",
|
||||
"content": {
|
||||
@@ -1581,6 +1292,13 @@
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"_whitespace": {
|
||||
"type": "TOKEN",
|
||||
"content": {
|
||||
"type": "PATTERN",
|
||||
"value": "\\s"
|
||||
}
|
||||
}
|
||||
},
|
||||
"extras": [
|
||||
@@ -1589,30 +1307,18 @@
|
||||
"name": "comment"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": " "
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "\t"
|
||||
"type": "SYMBOL",
|
||||
"name": "_whitespace"
|
||||
}
|
||||
],
|
||||
"conflicts": [
|
||||
[
|
||||
"string_lit",
|
||||
"quoted_template"
|
||||
],
|
||||
[
|
||||
"block",
|
||||
"one_line_block"
|
||||
]
|
||||
],
|
||||
"precedences": [],
|
||||
"externals": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_newline"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_quoted_template_start"
|
||||
|
||||
@@ -117,7 +117,7 @@
|
||||
"fields": {},
|
||||
"children": {
|
||||
"multiple": true,
|
||||
"required": false,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "attribute",
|
||||
@@ -126,10 +126,6 @@
|
||||
{
|
||||
"type": "block",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "one_line_block",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -179,7 +175,7 @@
|
||||
"fields": {},
|
||||
"children": {
|
||||
"multiple": false,
|
||||
"required": true,
|
||||
"required": false,
|
||||
"types": [
|
||||
{
|
||||
"type": "body",
|
||||
@@ -488,6 +484,11 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "numeric_lit",
|
||||
"named": true,
|
||||
"fields": {}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"named": true,
|
||||
@@ -518,29 +519,6 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "one_line_block",
|
||||
"named": true,
|
||||
"fields": {},
|
||||
"children": {
|
||||
"multiple": true,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "expression",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "identifier",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "string_lit",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "operation",
|
||||
"named": true,
|
||||
@@ -878,10 +856,6 @@
|
||||
"type": "null_lit",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "numeric_lit",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "strip_marker",
|
||||
"named": true
|
||||
|
||||
25382
src/parser.c
25382
src/parser.c
File diff suppressed because it is too large
Load Diff
@@ -5,7 +5,6 @@
|
||||
#include <stdio.h>
|
||||
|
||||
enum TokenType {
|
||||
NEWLINE,
|
||||
QUOTED_TEMPLATE_START,
|
||||
QUOTED_TEMPLATE_END,
|
||||
TEMPLATE_LITERAL_CHUNK,
|
||||
@@ -48,7 +47,6 @@ void print_debug_info(Scanner *scanner, TSLexer *lexer, const bool *valid_symbol
|
||||
printf("template_literal_chunk: %x\n", valid_symbols[TEMPLATE_LITERAL_CHUNK]);
|
||||
printf("template_interpolation_start: %x\n", valid_symbols[TEMPLATE_INTERPOLATION_START]);
|
||||
printf("template_interpolation_end: %x\n", valid_symbols[TEMPLATE_INTERPOLATION_END]);
|
||||
printf("newline: %x\n", valid_symbols[NEWLINE]);
|
||||
printf("\n");
|
||||
printf("scanner state:\n");
|
||||
printf("in_template_interpolation %x\n", scanner->in_template_interpolation);
|
||||
@@ -86,31 +84,13 @@ void scanner_exit_quoted_context(Scanner *scanner) {
|
||||
}
|
||||
}
|
||||
|
||||
bool is_newline(char c) {
|
||||
return c == '\n' || c == '\r';
|
||||
}
|
||||
|
||||
bool is_skippable_whitespace_outside_of_quoted_context(char c) {
|
||||
return c == ' ' || c == '\t';
|
||||
}
|
||||
|
||||
bool scanner_scan(Scanner *scanner, TSLexer *lexer, const bool *valid_symbols) {
|
||||
// print_debug_info(scanner, lexer, valid_symbols);
|
||||
|
||||
while (
|
||||
is_skippable_whitespace_outside_of_quoted_context(lexer->lookahead) &&
|
||||
!scanner->in_quoted_context
|
||||
) {
|
||||
while (iswspace(lexer->lookahead) && !scanner->in_quoted_context) {
|
||||
skip(lexer);
|
||||
}
|
||||
|
||||
if (valid_symbols[NEWLINE] &&
|
||||
is_newline(lexer->lookahead) &&
|
||||
scanner->quoted_context_depth == 0
|
||||
) {
|
||||
return accept_and_advance(lexer, NEWLINE);
|
||||
}
|
||||
|
||||
// manage quoted context
|
||||
if (
|
||||
valid_symbols[QUOTED_TEMPLATE_START] &&
|
||||
@@ -162,9 +142,6 @@ bool scanner_scan(Scanner *scanner, TSLexer *lexer, const bool *valid_symbols) {
|
||||
//
|
||||
// they may not contain newlines and may contain escape sequences
|
||||
if (valid_symbols[TEMPLATE_LITERAL_CHUNK] && scanner->in_quoted_context) {
|
||||
if (is_newline(lexer->lookahead)) {
|
||||
return false;
|
||||
}
|
||||
switch (lexer->lookahead) {
|
||||
case '\\':
|
||||
advance(lexer);
|
||||
|
||||
Reference in New Issue
Block a user