simplify whitespace handling; support hexadecimal numeric literals; allow empty configs

This commit is contained in:
mhoffm
2021-06-20 00:03:58 +02:00
parent b1c3109853
commit 22d0a7253c
15 changed files with 12984 additions and 13226 deletions

View File

@@ -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"