Option

Home > Textual Syntax Specification > Specification Language > Option

Option is similar to the Java abbreviatory if-then-else notation: (condition ? then case : else case). Dependent on the object state a different syntax might apply.

The textual syntax definition of the "Option" class is as follows:

Option : "(" (P:predicate) _ "?" _ (P:thenCase) _ ":" _ (P:elseCase) ")" ;

Here's an example how to use that statement within a textual syntax definition:

Component : ((bool)(P:isPublic) ? "public" : "private") _ "Component" _ (P:name) ;
  • The "Option" is put into parentheses.
  • There's a predicate defined before the question mark. In the example above the "isPublic" property of the "Component" class is referenced by the statement P:isPublic and finally casted to a predicate by the (bool)(...) statement. (bool)(...) is – by the way – the textual representation of the "CastEdgeToPredicate" class which is part of the metapackage "org.oomega.query".
  • After the question mark and before the colon there's the syntax template of the "then" case defined. That syntax template is again a vector of template elements.
  • After the colon there's the syntax template of the "else" case defined. That syntax template is again a vector of template elements.

Next chapter: Non Terminal

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.