Binary operations, control structures
This commit is contained in:
@@ -0,0 +1,23 @@
|
|||||||
|
if
|
||||||
|
: "if" "(" expression ")" expression ("else" expression)?
|
||||||
|
;
|
||||||
|
|
||||||
|
match
|
||||||
|
: expression "match" "{" matchEntry+ "}"
|
||||||
|
;
|
||||||
|
|
||||||
|
matchEntry
|
||||||
|
: "case" pattern "=>" expression // TODO: Consider other options than "=>"
|
||||||
|
;
|
||||||
|
|
||||||
|
for
|
||||||
|
: "for" "(" valOrVar? (SimpleName | parameter) "in" expression ")" expression
|
||||||
|
;
|
||||||
|
|
||||||
|
while
|
||||||
|
: "while" "(" expression ")" expression
|
||||||
|
;
|
||||||
|
|
||||||
|
doWhile
|
||||||
|
: "do" expression "while" "(" expression ")"
|
||||||
|
;
|
||||||
@@ -10,24 +10,39 @@ expression
|
|||||||
: binOpExpression
|
: binOpExpression
|
||||||
: unOpExpression
|
: unOpExpression
|
||||||
: name functionParameters? // TODO: ambiguity here
|
: name functionParameters? // TODO: ambiguity here
|
||||||
|
: infixFunctionCall
|
||||||
|
: arrayAccess
|
||||||
|
: match
|
||||||
: FieldName
|
: FieldName
|
||||||
: if
|
: if
|
||||||
// TODO: list comprehension
|
// TODO: list comprehension
|
||||||
: jump
|
: jump
|
||||||
;
|
;
|
||||||
|
|
||||||
binaryOperation
|
binaryOperation // Decreasing precedence
|
||||||
: "+" : "-" : "*" : "/"
|
: "*" : "/" // No %
|
||||||
: "|" : "||" : "&" : "&&" : "^" // Maybe we can drop "^"
|
: "+" : "-"
|
||||||
: "<" : ">" : ">=" : "<="
|
// No << >> >>>
|
||||||
|
: "<" : ">" : ">=" : "<=" : "is" : "isnot" : "in" // TODO: Check the precedence for in carefully
|
||||||
: "==" : "==="
|
: "==" : "==="
|
||||||
: "in"
|
// No | & ^ ~
|
||||||
: "is" : "isnot"
|
: "&&"
|
||||||
|
: "||"
|
||||||
;
|
;
|
||||||
|
|
||||||
unaryOperation
|
assignments
|
||||||
|
: "="
|
||||||
|
: "+=" : "-=" : "*=" : "/=" // TODO: |=, %= and <<= make more sense than |, % or << alone, and so for others
|
||||||
|
;
|
||||||
|
|
||||||
|
prefixUnaryOperation
|
||||||
: "-" : "+"
|
: "-" : "+"
|
||||||
: "!"
|
: "++" : "--"
|
||||||
|
: "!" // No ~
|
||||||
|
;
|
||||||
|
|
||||||
|
postfixUnaryOperation
|
||||||
|
: "++" : "--"
|
||||||
;
|
;
|
||||||
|
|
||||||
jump
|
jump
|
||||||
|
|||||||
Reference in New Issue
Block a user