Fix parsing of negative numbers (#12)

* Add failing test for negative numbers

* Fix parsing of negative numbers

* Rearrange assertion to avoid extra diff noise
This commit is contained in:
Ryan Tsao 2021-03-04 15:25:23 -08:00 committed by GitHub
parent 9668e88916
commit 94e1023093
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 1500 additions and 1565 deletions

View File

@ -86,6 +86,7 @@ a {
c: 5em; c: 5em;
margin: 10E3px; margin: 10E3px;
margin: -456.8px; margin: -456.8px;
margin: -5px;
margin: -0.0px; margin: -0.0px;
} }
@ -97,6 +98,7 @@ a {
(declaration (property_name) (integer_value (unit))) (declaration (property_name) (integer_value (unit)))
(declaration (property_name) (float_value (unit))) (declaration (property_name) (float_value (unit)))
(declaration (property_name) (float_value (unit))) (declaration (property_name) (float_value (unit)))
(declaration (property_name) (integer_value (unit)))
(declaration (property_name) (float_value (unit)))))) (declaration (property_name) (float_value (unit))))))
============================ ============================
@ -240,5 +242,5 @@ a-property: calc(5px + var(--a-variable));
--- ---
(stylesheet (stylesheet
(declaration (property_name) (plain_value)) (declaration (property_name) (integer_value (unit)))
(declaration (property_name) (call_expression (function_name) (arguments (binary_expression (integer_value (unit)) (call_expression (function_name) (arguments (plain_value)))))))) (declaration (property_name) (call_expression (function_name) (arguments (binary_expression (integer_value (unit)) (call_expression (function_name) (arguments (plain_value))))))))

View File

@ -333,7 +333,7 @@ module.exports = grammar({
')' ')'
), ),
identifier: $ => /[a-zA-Z-_][a-zA-Z0-9-_]*/, identifier: $ => /(--|-?[a-zA-Z_])[a-zA-Z0-9-_]*/,
at_keyword: $ => /@[a-zA-Z-_]+/, at_keyword: $ => /@[a-zA-Z-_]+/,

2
src/grammar.json vendored
View File

@ -1642,7 +1642,7 @@
}, },
"identifier": { "identifier": {
"type": "PATTERN", "type": "PATTERN",
"value": "[a-zA-Z-_][a-zA-Z0-9-_]*" "value": "(--|-?[a-zA-Z_])[a-zA-Z0-9-_]*"
}, },
"at_keyword": { "at_keyword": {
"type": "PATTERN", "type": "PATTERN",

3057
src/parser.c vendored

File diff suppressed because it is too large Load Diff