Add binary expressions
This commit is contained in:
parent
3e106ca94e
commit
8ba3d11be0
|
@ -54,6 +54,28 @@ a {
|
|||
(declaration (property_name) (float_value (unit)))
|
||||
(declaration (property_name) (integer_value (unit))))))
|
||||
|
||||
============================
|
||||
Binary arithmetic operators
|
||||
============================
|
||||
|
||||
a {
|
||||
width: calc(100% - 80px);
|
||||
aspect-ratio: 1/2;
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(stylesheet
|
||||
(rule_set
|
||||
(selectors (tag_name))
|
||||
(block
|
||||
(declaration
|
||||
(property_name)
|
||||
(call_expression (function_name) (arguments (binary_expression (integer_value (unit)) (integer_value (unit))))))
|
||||
(declaration
|
||||
(property_name)
|
||||
(binary_expression (integer_value) (integer_value))))))
|
||||
|
||||
============================
|
||||
Strings
|
||||
============================
|
||||
|
|
|
@ -185,6 +185,7 @@ module.exports = grammar({
|
|||
$.integer_value,
|
||||
$.float_value,
|
||||
$.string_value,
|
||||
$.binary_expression,
|
||||
$.call_expression
|
||||
),
|
||||
|
||||
|
@ -223,6 +224,12 @@ module.exports = grammar({
|
|||
$.arguments
|
||||
),
|
||||
|
||||
binary_expression: $ => prec.left(seq(
|
||||
$._value,
|
||||
choice('+', '-', '*', '/'),
|
||||
$._value
|
||||
)),
|
||||
|
||||
arguments: $ => seq(
|
||||
token.immediate('('),
|
||||
commaSep($._value),
|
||||
|
|
|
@ -786,6 +786,10 @@
|
|||
"type": "SYMBOL",
|
||||
"name": "string_value"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "binary_expression"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "call_expression"
|
||||
|
@ -1039,6 +1043,44 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"binary_expression": {
|
||||
"type": "PREC_LEFT",
|
||||
"value": 0,
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_value"
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "+"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "-"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "*"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "/"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_value"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"arguments": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue