fix numeric literals

This commit is contained in:
mhoffm
2021-06-07 22:32:14 +02:00
parent 970f93f301
commit e67d183d71
5 changed files with 473 additions and 1317 deletions

2
.gitignore vendored
View File

@@ -6,6 +6,8 @@ yarn-debug.log*
yarn-error.log*
lerna-debug.log*
tmp
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

View File

@@ -1,5 +1,4 @@
const
newline = '\n',
space = ' ',
decimal = /[0-9]/
@@ -23,7 +22,6 @@ module.exports = grammar({
$.attribute,
$.block,
),
repeat1(newline),
)),
attribute: $ => seq(
@@ -36,9 +34,7 @@ module.exports = grammar({
$.identifier,
repeat(choice($.string_lit, $.identifier)),
'{',
repeat1(newline),
optional($.body),
// newline is handled in body
'}',
),
@@ -70,11 +66,7 @@ module.exports = grammar({
'null',
),
numeric_lit: $ => seq(
repeat1(decimal),
optional(seq('.', repeat1(decimal))),
optional(seq(choice('e', 'E'), optional(choice('+', '-')), repeat1(decimal))),
),
numeric_lit: $ => /[0-9]+(\.[0-9]+([eE][-+]?[0-9]+)?)?/,
variable_expr: $ => $.identifier,

View File

@@ -22,13 +22,6 @@
"name": "block"
}
]
},
{
"type": "REPEAT1",
"content": {
"type": "STRING",
"value": "\n"
}
}
]
}
@@ -77,13 +70,6 @@
"type": "STRING",
"value": "{"
},
{
"type": "REPEAT1",
"content": {
"type": "STRING",
"value": "\n"
}
},
{
"type": "CHOICE",
"members": [
@@ -167,94 +153,8 @@
]
},
"numeric_lit": {
"type": "SEQ",
"members": [
{
"type": "REPEAT1",
"content": {
"type": "PATTERN",
"value": "[0-9]"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "."
},
{
"type": "REPEAT1",
"content": {
"type": "PATTERN",
"value": "[0-9]"
}
}
]
},
{
"type": "BLANK"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "e"
},
{
"type": "STRING",
"value": "E"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "+"
},
{
"type": "STRING",
"value": "-"
}
]
},
{
"type": "BLANK"
}
]
},
{
"type": "REPEAT1",
"content": {
"type": "PATTERN",
"value": "[0-9]"
}
}
]
},
{
"type": "BLANK"
}
]
}
]
"type": "PATTERN",
"value": "[0-9]+(\\.[0-9]+([eE][-+]?[0-9]+)?)?"
},
"variable_expr": {
"type": "SYMBOL",

View File

@@ -137,11 +137,6 @@
]
}
},
{
"type": "numeric_lit",
"named": true,
"fields": {}
},
{
"type": "string_lit",
"named": true,
@@ -162,10 +157,6 @@
]
}
},
{
"type": "\n",
"named": false
},
{
"type": "\"",
"named": false
@@ -178,34 +169,14 @@
"type": ")",
"named": false
},
{
"type": "+",
"named": false
},
{
"type": "-",
"named": false
},
{
"type": ".",
"named": false
},
{
"type": "=",
"named": false
},
{
"type": "E",
"named": false
},
{
"type": "comment",
"named": true
},
{
"type": "e",
"named": false
},
{
"type": "false",
"named": false
@@ -214,6 +185,10 @@
"type": "null",
"named": false
},
{
"type": "numeric_lit",
"named": true
},
{
"type": "true",
"named": false

File diff suppressed because it is too large Load Diff