Commits

Victor Kotseruba committed 76308be

expression grammar

Comments (0)

Files changed (1)

 
 NAME = Word(alphas + '-')
 
-NUMBER = Word(alphanums) # XXX
+NUMBER = Regex(r'-?\d+(?:\.\d+)?(?:px|em|pt|%)?')
 OPERATOR = Literal('+') | Literal('-') | Literal('/') | Literal('*')
 STRING = QuotedString(quoteChar='"') | QuotedString(quoteChar="'")
 VARIABLE = Regex(r'![\w-]+')
-EXPR_RIGHT = (NUMBER | STRING | VARIABLE)
-EXPR_LEFT = EXPR_RIGHT + OPERATOR
-EXPRESSION = Group(ZeroOrMore(EXPR_LEFT) + EXPR_RIGHT)
+EXPRESSION = Forward()
+ATOM = (NUMBER | VARIABLE | STRING) | (Suppress('(') + Group(EXPRESSION) + Suppress(')'))
+EXPRESSION << ATOM + ZeroOrMore(OPERATOR + ATOM)
+
+
 
 PROP_VALUE = EXPRESSION
 
     pass: pass
 
 .wrap
-    width = 1px + 2px
+    :width = 1px + 2px + (2 * 3px + (!width)) + !k
     
     :border
         color: red