more tests
This commit is contained in:
@@ -75,7 +75,7 @@ module.exports = grammar({
|
|||||||
|
|
||||||
numeric_lit: $ => /[0-9]+(\.[0-9]+([eE][-+]?[0-9]+)?)?/,
|
numeric_lit: $ => /[0-9]+(\.[0-9]+([eE][-+]?[0-9]+)?)?/,
|
||||||
|
|
||||||
string_lit: $ => seq('"', repeat(choice(/[^\\"\n]/, /\\(.|\n)/)), '"'),
|
string_lit: $ => (seq('"', token.immediate(repeat(choice(/[^\\"\n]/, /\\(.|\n)/))), '"')),
|
||||||
|
|
||||||
bool_lit: $ => choice('true', 'false'),
|
bool_lit: $ => choice('true', 'false'),
|
||||||
|
|
||||||
|
|||||||
@@ -247,19 +247,22 @@
|
|||||||
"value": "\""
|
"value": "\""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "REPEAT",
|
"type": "IMMEDIATE_TOKEN",
|
||||||
"content": {
|
"content": {
|
||||||
"type": "CHOICE",
|
"type": "REPEAT",
|
||||||
"members": [
|
"content": {
|
||||||
{
|
"type": "CHOICE",
|
||||||
"type": "PATTERN",
|
"members": [
|
||||||
"value": "[^\\\\\"\\n]"
|
{
|
||||||
},
|
"type": "PATTERN",
|
||||||
{
|
"value": "[^\\\\\"\\n]"
|
||||||
"type": "PATTERN",
|
},
|
||||||
"value": "\\\\(.|\\n)"
|
{
|
||||||
}
|
"type": "PATTERN",
|
||||||
]
|
"value": "\\\\(.|\\n)"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
2987
src/parser.c
2987
src/parser.c
File diff suppressed because it is too large
Load Diff
139
test/corpus/expressions.txt
Normal file
139
test/corpus/expressions.txt
Normal file
@@ -0,0 +1,139 @@
|
|||||||
|
==================
|
||||||
|
numeric literal scientific notation 1
|
||||||
|
==================
|
||||||
|
|
||||||
|
pi = 3
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(config_file
|
||||||
|
(body
|
||||||
|
(attribute
|
||||||
|
(identifier)
|
||||||
|
(expression
|
||||||
|
(expr_term
|
||||||
|
(literal_value
|
||||||
|
(numeric_lit)))))))
|
||||||
|
|
||||||
|
==================
|
||||||
|
numeric literal scientific notation 2
|
||||||
|
==================
|
||||||
|
|
||||||
|
pi = 3.14
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(config_file
|
||||||
|
(body
|
||||||
|
(attribute
|
||||||
|
(identifier)
|
||||||
|
(expression
|
||||||
|
(expr_term
|
||||||
|
(literal_value
|
||||||
|
(numeric_lit)))))))
|
||||||
|
|
||||||
|
==================
|
||||||
|
numeric literal scientific notation 3
|
||||||
|
==================
|
||||||
|
|
||||||
|
big_pi = 3.14e+10
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(config_file
|
||||||
|
(body
|
||||||
|
(attribute
|
||||||
|
(identifier)
|
||||||
|
(expression
|
||||||
|
(expr_term
|
||||||
|
(literal_value
|
||||||
|
(numeric_lit)))))))
|
||||||
|
|
||||||
|
==================
|
||||||
|
numeric literal scientific notation 4
|
||||||
|
==================
|
||||||
|
|
||||||
|
big_pi = 3.14E+10
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(config_file
|
||||||
|
(body
|
||||||
|
(attribute
|
||||||
|
(identifier)
|
||||||
|
(expression
|
||||||
|
(expr_term
|
||||||
|
(literal_value
|
||||||
|
(numeric_lit)))))))
|
||||||
|
|
||||||
|
==================
|
||||||
|
numeric literal scientific notation 5
|
||||||
|
==================
|
||||||
|
|
||||||
|
small_pi = 3.14e-10
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(config_file
|
||||||
|
(body
|
||||||
|
(attribute
|
||||||
|
(identifier)
|
||||||
|
(expression
|
||||||
|
(expr_term
|
||||||
|
(literal_value
|
||||||
|
(numeric_lit)))))))
|
||||||
|
|
||||||
|
|
||||||
|
==================
|
||||||
|
numeric literal scientific notation 6
|
||||||
|
==================
|
||||||
|
|
||||||
|
small_pi = 3.14E-10
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(config_file
|
||||||
|
(body
|
||||||
|
(attribute
|
||||||
|
(identifier)
|
||||||
|
(expression
|
||||||
|
(expr_term
|
||||||
|
(literal_value
|
||||||
|
(numeric_lit)))))))
|
||||||
|
|
||||||
|
==================
|
||||||
|
string literal one line
|
||||||
|
==================
|
||||||
|
|
||||||
|
foo = "bar"
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(config_file
|
||||||
|
(body
|
||||||
|
(attribute
|
||||||
|
(identifier)
|
||||||
|
(expression
|
||||||
|
(expr_term
|
||||||
|
(literal_value
|
||||||
|
(string_lit)))))))
|
||||||
|
|
||||||
|
|
||||||
|
==================
|
||||||
|
string literal multi line error
|
||||||
|
==================
|
||||||
|
|
||||||
|
foo = "
|
||||||
|
bar"
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(config_file
|
||||||
|
(body
|
||||||
|
(attribute
|
||||||
|
(identifier)
|
||||||
|
(expression
|
||||||
|
(expr_term
|
||||||
|
(literal_value
|
||||||
|
(string_lit (ERROR (UNEXPECTED 'b')))))))))
|
||||||
|
|
||||||
Reference in New Issue
Block a user