Add parenthesized expressions

This commit is contained in:
Max Brunsfeld 2018-10-29 15:35:49 -07:00
parent e2a44c9650
commit 3c2035e98e
4 changed files with 3722 additions and 3593 deletions

View File

@ -106,6 +106,7 @@ Binary arithmetic operators
a {
width: calc(100% - 80px);
aspect-ratio: 1/2;
font-size: calc(10px + (56 - 10) * ((100vw - 320px) / (1920 - 320)));
}
---
@ -119,7 +120,20 @@ a {
(call_expression (function_name) (arguments (binary_expression (integer_value (unit)) (integer_value (unit))))))
(declaration
(property_name)
(binary_expression (integer_value) (integer_value))))))
(binary_expression (integer_value) (integer_value)))
(declaration
(property_name)
(call_expression
(function_name)
(arguments
(binary_expression
(binary_expression
(integer_value (unit))
(parenthesized_value (binary_expression (integer_value) (integer_value))))
(parenthesized_value
(binary_expression
(parenthesized_value (binary_expression (integer_value (unit)) (integer_value (unit))))
(parenthesized_value (binary_expression (integer_value) (integer_value))))))))))))
============================
Strings

View File

@ -261,9 +261,16 @@ module.exports = grammar({
$.float_value,
$.string_value,
$.binary_expression,
$.parenthesized_value,
$.call_expression
)),
parenthesized_value: $ => seq(
'(',
$._value,
')'
),
color_value: $ => seq('#', token.immediate(/[0-9a-fA-F]{3,8}/)),
string_value: $ => token(choice(

29
src/grammar.json vendored
View File

@ -1197,6 +1197,10 @@
"type": "SYMBOL",
"name": "binary_expression"
},
{
"type": "SYMBOL",
"name": "parenthesized_value"
},
{
"type": "SYMBOL",
"name": "call_expression"
@ -1204,6 +1208,23 @@
]
}
},
"parenthesized_value": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "("
},
{
"type": "SYMBOL",
"name": "_value"
},
{
"type": "STRING",
"value": ")"
}
]
},
"color_value": {
"type": "SEQ",
"members": [
@ -1560,10 +1581,6 @@
"type": "PATTERN",
"value": "[a-zA-Z-_][a-zA-Z0-9-_]*"
},
"plain_value": {
"type": "PATTERN",
"value": "[a-zA-Z-_][^;()\\[\\]\\s]*"
},
"at_keyword": {
"type": "PATTERN",
"value": "@[a-zA-Z-_]+"
@ -1587,6 +1604,10 @@
}
]
}
},
"plain_value": {
"type": "PATTERN",
"value": "[-_]*[a-zA-Z][^;()\\[\\]\\s]*"
}
},
"extras": [

7263
src/parser.c vendored

File diff suppressed because it is too large Load Diff