Xbase provides predefined expressions for your language as discussed on these pages. This provides XExpression which contains not only '+', '-', '*' and so on but also statements like 'if', while' and so on.
The grammar for org.eclipse.xtext.xbase.Xbase is here.
| Grammar Rule | Grammar Definition | ||
|---|---|---|---|
| XExpression | |||
| XCastedExpression | XMemberFeatureCall 'as' JvmTypeReference* | ||
| XIfExpression | 'if' '(' XExpression ')' XExpression ('else' XExpression)? | ||
| XSwitchExpression | 'switch' (ValidID ':')? XExpression | '(' ValidID ':') XExpression ')' '{' XCasePart)+ (':' XExpression )?}' |
||
| XCasePart | JvmTypeReference? ('case' XExpression)? ':' XExpression | ||
| XForLoopExpression | 'for' '(' JvmFormalParameter ':' XExpression ')' XExpression | ||
| XWhileExpression | 'while' '(' XExpression ')' XExpression | ||
| XDoWhileExpression | 'do' XExpression 'while' '(' XExpression ')' | ||
| XBlockExpression | '{' (XExpressionInsideBlock ';'?)* '}' | ||
| XThrowExpression | 'throw' XExpression | ||
| XReturnExpression | 'return' XExpression? | ||
| XTryCatchFinallyExpression | 'try' XExpression ( XCatchClause+ ('finally' XExpression)? | 'finally' XExpression | ||
| XCatchClause | 'catch' '(' FullJvmFormalParameter ')' XExpression |
The above structures are built into Xbase, if you need a grammar with expressions/statements which are different in some way then you may want to consider a grammar generator here (Xgener) . This will produce an Xbase-like grammar which can be customised (but not the other capabilities of Xbase).
Here is a railroad diagram for Xbase to show the grammar.
| JvmTypeReference | |||
| XFunctionTypeRef | |||
| JvmParameterizedTypeReference | |||
| JvmArgumentTypeReference | |||
| JvmWildcardTypeReference | |||
| JvmTypeParameter | |||
| QualifiedName | |||
| ValidID | |||
|
metadata block |
|
| see also: |
|
| Correspondence about this page |
|
This site may have errors. Don't use for critical systems.
Copyright (c) 1998-2023 Martin John Baker - All rights reserved - privacy policy.