diff options
Diffstat (limited to 'language')
-rw-r--r-- | language/expression.rst | 81 | ||||
-rw-r--r-- | language/index.rst | 1 |
2 files changed, 82 insertions, 0 deletions
diff --git a/language/expression.rst b/language/expression.rst new file mode 100644 index 0000000..60c81c7 --- /dev/null +++ b/language/expression.rst @@ -0,0 +1,81 @@ +Expressions +----------- + +.. crowbar:element:: AtomicExpression <- identifier / constant / string-literal / '(' Expression ')' + +.. crowbar:element:: ObjectExpression <- AtomicExpression ObjectSuffix* / ArrayLiteral / StructLiteral + ObjectSuffix <- ArrayIndexSuffix / FunctionCallSuffix / StructElementSuffix / StructPointerElementSuffix + +.. crowbar:element:: ArrayIndexSuffix <- '[' Expression ']' + +.. crowbar:element:: FunctionCallSuffix <- '(' CommasExpressionList? ')' + CommasExpressionList <- Expression (',' Expression)* ','? + +.. crowbar:element:: StructElementSuffix <- '.' identifier + +.. crowbar:element:: StructPointerElementSuffix <- '->' identifier + +.. crowbar:element:: ArrayLiteral <- '{' CommasExpressionList '}' + +.. crowbar:element:: StructLiteral <- '{' StructLiteralElement (',' StructLiteralElement)* ','? '}' + StructLiteralElement <- '.' identifier '=' Expression + +.. crowbar:element:: FactorExpression <- CastExpression / AddressOfExpression / DerefExpression / PositiveExpression / NegativeExpression / BitwiseNotExpression / LogicalNotExpression / SizeofExpression / ObjectExpression + +.. crowbar:element:: CastExpression <- '(' Type ')' ObjectExpression + +.. crowbar:element:: AddressOfExpression <- '&' ObjectExpression + +.. crowbar:element:: DerefExpression <- '*' ObjectExpression + +.. crowbar:element:: PositiveExpression <- '+' ObjectExpression + +.. crowbar:element:: NegativeExpression <- '-' ObjectExpression + +.. crowbar:element:: BitwiseNotExpression <- '~' ObjectExpression + +.. crowbar:element:: LogicalNotExpression <- '!' ObjectExpression + +.. crowbar:element:: SizeofExpression <- 'sizeof' ObjectExpression / 'sizeof' Type + +.. crowbar:element:: TermExpression <- FactorExpression TermSuffix? + TermSuffix <- ('*' FactorExpression)+ / ('/' FactorExpression)+ / ('%' FactorExpression)+ + +.. crowbar:element:: ArithmeticExpression <- TermExpression ArithmeticSuffix? + ArithmeticSuffix <- ('+' TermExpression)+ / ('-' TermExpression)+ + +.. crowbar:element:: BitwiseOpExpression <- ShiftExpression / XorExpression / BitwiseAndExpression / BitwiseOrExpression / ArithmeticExpression + +.. crowbar:element:: ShiftExpression <- ArithmeticExpression '<<' ArithmeticExpression / ArithmeticExpression '>>' ArithmeticExpression + +.. crowbar:element:: XorExpression <- ArithmeticExpression '^' ArithmeticExpression + +.. crowbar:element:: BitwiseAndExpression <- ArithmeticExpression ('&' ArithmeticExpression)+ + +.. crowbar:element:: BitwiseOrExpression <- ArithmeticExpression ('|' ArithmeticExpression)+ + +.. crowbar:element:: ComparisonExpression <- EqualExpression / NotEqualExpression / LessEqExpression / GreaterEqExpression / LessThanExpression / GreaterThanExpression / BitwiseOpExpression + +.. crowbar:element:: EqualExpression <- BitwiseOpExpression '==' BitwiseOpExpression + +.. crowbar:element:: NotEqualExpression <- BitwiseOpExpression '!=' BitwiseOpExpression + +.. crowbar:element:: LessEqExpression <- BitwiseOpExpression '<=' BitwiseOpExpression + +.. crowbar:element:: GreaterEqExpression <- BitwiseOpExpression '>=' BitwiseOpExpression + +.. crowbar:element:: LessThanExpression <- BitwiseOpExpression '<' BitwiseOpExpression + +.. crowbar:element:: GreaterThanExpression <- BitwiseOpExpression '>' BitwiseOpExpression + +.. crowbar:element:: LogicalOpExpression <- LogicalAndExpression / LogicalOrExpression / ComparisonExpression + +.. crowbar:element:: LogicalAndExpression <- ComparisonExpression ('&&' ComparisonExpression)+ + +.. crowbar:element:: LogicalOrExpression <- ComparisonExpression ('||' ComparisonExpression)+ + +.. crowbar:element:: Expression <- LogicalOpExpression + +.. todo:: literally all the expression definitions + +.. todo:: figure out if this hierarchy can be tidied up diff --git a/language/index.rst b/language/index.rst index 3f776f9..7d11d4f 100644 --- a/language/index.rst +++ b/language/index.rst @@ -21,3 +21,4 @@ Syntax elements in this document are given in the form of `parsing expression gr functions statements/index types + expression |