Allow empty strings

This commit is contained in:
Max Brunsfeld 2018-10-22 20:20:36 -07:00
parent 9db3a5155d
commit a34b06cb86
4 changed files with 925 additions and 917 deletions

View File

@ -37,3 +37,21 @@ a {
(block
(declaration (property_name) (color_value))
(declaration (property_name) (color_value)))))
============================
Strings
============================
a {
b: '';
c: '\'hi\'';
}
---
(stylesheet
(rule_set
(selectors (tag_name))
(block
(declaration (property_name) (string_value))
(declaration (property_name) (string_value)))))

View File

@ -191,8 +191,8 @@ module.exports = grammar({
color_value: $ => /#[0-9a-fA-F]{3,8}/,
string_value: $ => token(choice(
seq("'", /([^'\n]|\\(.|\n))+/, "'"),
seq('"', /([^"\n]|\\(.|\n))+/, '"')
seq("'", /([^'\n]|\\(.|\n))*/, "'"),
seq('"', /([^"\n]|\\(.|\n))*/, '"')
)),
integer_value: $ => seq(

4
src/grammar.json vendored
View File

@ -810,7 +810,7 @@
},
{
"type": "PATTERN",
"value": "([^']|\\\\.)+"
"value": "([^'\\n]|\\\\(.|\\n))*"
},
{
"type": "STRING",
@ -827,7 +827,7 @@
},
{
"type": "PATTERN",
"value": "([^\"]|\\\\.)+"
"value": "([^\"\\n]|\\\\(.|\\n))*"
},
{
"type": "STRING",

1816
src/parser.c vendored

File diff suppressed because it is too large Load Diff