4.8. Expressions

AtomicExpression <- identifier / constant / 'true' / 'false' / string-literal / '(' Expression ')'
ObjectExpression <- AtomicExpression ObjectSuffix* / ArrayLiteral / StructLiteral
ObjectSuffix <- ArrayIndexSuffix / FunctionCallSuffix / StructElementSuffix / StructPointerElementSuffix
ArrayIndexSuffix <- '[' Expression ']'
FunctionCallSuffix <- '(' CommasExpressionList? ')'
CommasExpressionList <- Expression (',' Expression)* ','?
StructElementSuffix <- '.' identifier
StructPointerElementSuffix <- '->' identifier
ArrayLiteral <- '{' CommasExpressionList '}'
StructLiteral <- '{' StructLiteralElement (',' StructLiteralElement)* ','? '}'
StructLiteralElement <- '.' identifier '=' Expression
FactorExpression <- CastExpression / AddressOfExpression / DerefExpression / PositiveExpression / NegativeExpression / BitwiseNotExpression / LogicalNotExpression / SizeofExpression / ObjectExpression
CastExpression <- '(' Type ')' ObjectExpression
AddressOfExpression <- '&' ObjectExpression
DerefExpression <- '*' ObjectExpression
PositiveExpression <- '+' ObjectExpression
NegativeExpression <- '-' ObjectExpression
BitwiseNotExpression <- '~' ObjectExpression
LogicalNotExpression <- '!' ObjectExpression
SizeofExpression <- 'sizeof' ObjectExpression / 'sizeof' Type
TermExpression <- FactorExpression TermSuffix?
TermSuffix <- ('*' FactorExpression)+ / ('/' FactorExpression)+ / ('%' FactorExpression)+
ArithmeticExpression <- TermExpression ArithmeticSuffix?
ArithmeticSuffix <- ('+' TermExpression)+ / ('-' TermExpression)+
BitwiseOpExpression <- ShiftExpression / XorExpression / BitwiseAndExpression / BitwiseOrExpression / ArithmeticExpression
ShiftExpression <- ArithmeticExpression '<<' ArithmeticExpression / ArithmeticExpression '>>' ArithmeticExpression
XorExpression <- ArithmeticExpression '^' ArithmeticExpression
BitwiseAndExpression <- ArithmeticExpression ('&' ArithmeticExpression)+
BitwiseOrExpression <- ArithmeticExpression ('|' ArithmeticExpression)+
ComparisonExpression <- EqualExpression / NotEqualExpression / LessEqExpression / GreaterEqExpression / LessThanExpression / GreaterThanExpression / BitwiseOpExpression
EqualExpression <- BitwiseOpExpression '==' BitwiseOpExpression
NotEqualExpression <- BitwiseOpExpression '!=' BitwiseOpExpression
LessEqExpression <- BitwiseOpExpression '<=' BitwiseOpExpression
GreaterEqExpression <- BitwiseOpExpression '>=' BitwiseOpExpression
LessThanExpression <- BitwiseOpExpression '<' BitwiseOpExpression
GreaterThanExpression <- BitwiseOpExpression '>' BitwiseOpExpression
LogicalOpExpression <- LogicalAndExpression / LogicalOrExpression / ComparisonExpression
LogicalAndExpression <- ComparisonExpression ('&&' ComparisonExpression)+
LogicalOrExpression <- ComparisonExpression ('||' ComparisonExpression)+
Expression <- LogicalOpExpression

Todo

literally all the expression definitions

Todo

figure out if this hierarchy can be tidied up