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
|
||||
: unOpExpression
|
||||
: name functionParameters? // TODO: ambiguity here
|
||||
: infixFunctionCall
|
||||
: arrayAccess
|
||||
: match
|
||||
: FieldName
|
||||
: if
|
||||
// TODO: list comprehension
|
||||
: jump
|
||||
;
|
||||
|
||||
binaryOperation
|
||||
: "+" : "-" : "*" : "/"
|
||||
: "|" : "||" : "&" : "&&" : "^" // Maybe we can drop "^"
|
||||
: "<" : ">" : ">=" : "<="
|
||||
binaryOperation // Decreasing precedence
|
||||
: "*" : "/" // No %
|
||||
: "+" : "-"
|
||||
// No << >> >>>
|
||||
: "<" : ">" : ">=" : "<=" : "is" : "isnot" : "in" // TODO: Check the precedence for in carefully
|
||||
: "==" : "==="
|
||||
: "in"
|
||||
: "is" : "isnot"
|
||||
// No | & ^ ~
|
||||
: "&&"
|
||||
: "||"
|
||||
;
|
||||
|
||||
unaryOperation
|
||||
assignments
|
||||
: "="
|
||||
: "+=" : "-=" : "*=" : "/=" // TODO: |=, %= and <<= make more sense than |, % or << alone, and so for others
|
||||
;
|
||||
|
||||
prefixUnaryOperation
|
||||
: "-" : "+"
|
||||
: "!"
|
||||
: "++" : "--"
|
||||
: "!" // No ~
|
||||
;
|
||||
|
||||
postfixUnaryOperation
|
||||
: "++" : "--"
|
||||
;
|
||||
|
||||
jump
|
||||
|
||||
Reference in New Issue
Block a user