|
|
[[chp:syntax]]
|
|
|
OPAL Language Syntax
|
|
|
--------------------
|
|
|
|
|
|
Words in _italic font_ are syntactic entities, and characters in
|
|
|
`monospaced font` must be entered as shown. Comments are given in *bold
|
|
|
font*.
|
|
|
|
|
|
[[statements]]
|
|
|
Statements:
|
|
|
~~~~~~~~~~~
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|============================================
|
|
|
|_comment_ |: |`//` _anything-except-newline_
|
|
|
| |`|` |`/*` __anything-except-__`*/` `*/`
|
|
|
|============================================
|
|
|
|
|
|
+
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|=======================================
|
|
|
|_identifier_ |: |`[a-zA-Z][a-zA-Z0-9-]`
|
|
|
|=======================================
|
|
|
|
|
|
+
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|======================
|
|
|
|_integer_ |: |`[0-9]+`
|
|
|
|======================
|
|
|
|
|
|
+
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|===================================================
|
|
|
|_string_ |: |`’`__anything-except-single-quote__`’`
|
|
|
| |`|` |`"`anything-except-double-quote`"`
|
|
|
|===================================================
|
|
|
|
|
|
+
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|=============================================
|
|
|
|_command_ |: |_keyword_ _attribute-list_
|
|
|
| |`|` |_label_ `:` _keyword_ _attribute-list_
|
|
|
|=============================================
|
|
|
|
|
|
+
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|==========================
|
|
|
|_keyword_ |: |_identifier_
|
|
|
|==========================
|
|
|
|
|
|
+
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|========================
|
|
|
|_label_ |: |_identifier_
|
|
|
|========================
|
|
|
|
|
|
+
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|=======================================
|
|
|
|_attribute-list_ |: |_empty_
|
|
|
| |`|` |_attribute-list_ `,` _attribute_
|
|
|
|=======================================
|
|
|
|
|
|
+
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|================================================================
|
|
|
|_attribute_ |: |_attribute-name_ *// only for logical attribute*
|
|
|
| |`|` |_attribute-name_ `=` _attribute-value_
|
|
|
| | |*// expression evaluated*
|
|
|
| |`|` |_attribute-name_ `:=` _attribute-value_
|
|
|
| | |*// expression retained*
|
|
|
|================================================================
|
|
|
|
|
|
+
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|=================================
|
|
|
|_attribute-name_ |: |_identifier_
|
|
|
|=================================
|
|
|
|
|
|
+
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|=========================================
|
|
|
|_attribute-value_ |: |_string-expression_
|
|
|
| |`|` |_logical-expression_
|
|
|
| |`|` |_real-expression_
|
|
|
| |`|` |_array-expression_
|
|
|
| |`|` |_constraint_
|
|
|
| |`|` |_variable-reference_
|
|
|
| |`|` |_place_
|
|
|
| |`|` |_range_
|
|
|
| |`|` |_token-list_
|
|
|
| |`|` |_token-list-array_
|
|
|
| |`|` |_regular-expression_
|
|
|
|=========================================
|
|
|
|
|
|
[[real-expressions]]
|
|
|
Real expressions:
|
|
|
~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|========================================
|
|
|
|_real-expression_ |: |_real-term_
|
|
|
| |`|` |`+` _real-term_
|
|
|
| |`|` |`-` _real-term_
|
|
|
| |`|` |_real-expression_ `+` _real-term_
|
|
|
| |`|` |_real-expression_ `-` _real-term_
|
|
|
|========================================
|
|
|
|
|
|
+
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|====================================
|
|
|
|_real-term_ |: |_real-factor_
|
|
|
| |`|` |_real-term_ `*` _real-factor_
|
|
|
| |`|` |_real-term_ `/` _real-factor_
|
|
|
|====================================
|
|
|
|
|
|
+
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|=======================================
|
|
|
|_real-factor_ |: |_real-primary_
|
|
|
| |`|` |_real-factor_ `^` _real-primary_
|
|
|
|=======================================
|
|
|
|
|
|
+
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|======================================================================
|
|
|
|_real-primary_ |: |_real-literal_
|
|
|
| |`|` |_symbolic-constant_
|
|
|
| |`|` |`#`
|
|
|
| |`|` |_real-name_
|
|
|
| |`|` |_array_ `[` _index_ `]`
|
|
|
| |`|` |_object-name_ `->` _real-attribute_
|
|
|
| |`|` |_object-name_ `->` _array-attribute_ `[` _index_ `]`
|
|
|
| |`|` |_table-reference_
|
|
|
| |`|` |_real-function_ `()`
|
|
|
| |`|` |_real-function_ `(` _real-expression_ `)`
|
|
|
| |`|` |_real-function_ `(` _real-expression_ `,` _real-expression_ `)`
|
|
|
| |`|` |_function-of-array_ `(` _array-expression_ `)`
|
|
|
| |`|` |`(` _real-expression_ `)`
|
|
|
|======================================================================
|
|
|
|
|
|
+
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|==========================
|
|
|
|_real-function_ |: |`RANF`
|
|
|
| |`|` |`GAUSS`
|
|
|
| |`|` |`ABS`
|
|
|
| |`|` |`TRUNC`
|
|
|
| |`|` |`ROUND`
|
|
|
| |`|` |`FLOOR`
|
|
|
| |`|` |`CEIL`
|
|
|
| |`|` |`SIGN`
|
|
|
| |`|` |`SQRT`
|
|
|
| |`|` |`LOG`
|
|
|
| |`|` |`EXP`
|
|
|
| |`|` |`SIN`
|
|
|
| |`|` |`COS`
|
|
|
| |`|` |`ABS`
|
|
|
| |`|` |`TAN`
|
|
|
| |`|` |`ASIN`
|
|
|
| |`|` |`ACOS`
|
|
|
| |`|` |`ATAN`
|
|
|
| |`|` |`ATAN2`
|
|
|
| |`|` |`MAX`
|
|
|
| |`|` |`MIN`
|
|
|
| |`|` |`MOD`
|
|
|
| |`|` |`POW`
|
|
|
|==========================
|
|
|
|
|
|
+
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|==============================
|
|
|
|_function-of-array_ |: |`VMIN`
|
|
|
| |`|` |`VMAX`
|
|
|
| |`|` |`VRMS`
|
|
|
| |`|` |`VABSMAX`
|
|
|
|==============================
|
|
|
|
|
|
[[real-variables-and-constants]]
|
|
|
Real variables and constants:
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|=======================
|
|
|
|_real-prefix_ |: |empty
|
|
|
| |`|` |`REAL`
|
|
|
| |`|` |`REAL CONST`
|
|
|
| |`|` |`CONST`
|
|
|
|=======================
|
|
|
|
|
|
+
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|=====================================================================
|
|
|
|_real-definition_ |: |_real-prefix_ _real-name_ `=` _real-expression_
|
|
|
| | |*// expression evaluated*
|
|
|
| |`|` |_real-prefix_ _real-name_ `:=` _real-expression_
|
|
|
| | |*// expression retained*
|
|
|
|=====================================================================
|
|
|
|
|
|
+
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|============================
|
|
|
|_symbolic-constant_ |: |`PI`
|
|
|
| |`|` |`TWOPI`
|
|
|
| |`|` |`DEGRAD`
|
|
|
| |`|` |`RADDEG`
|
|
|
| |`|` |`E`
|
|
|
| |`|` |`EMASS`
|
|
|
| |`|` |`PMASS`
|
|
|
| |`|` |`HMMASS`
|
|
|
| |`|` |`UMASS`
|
|
|
| |`|` |`CMASS`
|
|
|
| |`|` |`MMASS`
|
|
|
| |`|` |`DMASS`
|
|
|
| |`|` |`XEMASS`
|
|
|
| |`|` |`CLIGHT`
|
|
|
| |`|` |_real-name_
|
|
|
|============================
|
|
|
|
|
|
+
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|============================
|
|
|
|_real-name_ |: |_identifier_
|
|
|
|============================
|
|
|
|
|
|
+
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|==============================
|
|
|
|_object-name_ |: |_identifier_
|
|
|
|==============================
|
|
|
|
|
|
+
|
|
|
+
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|=============================
|
|
|
|_table-name_ |: |_identifier_
|
|
|
|=============================
|
|
|
|
|
|
+
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|==============================
|
|
|
|_column-name_ |: |_identifier_
|
|
|
|==============================
|
|
|
|
|
|
[[logical-expressions]]
|
|
|
Logical expressions:
|
|
|
~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|=================================================
|
|
|
|_logical-expression_ |: |_and-expression_
|
|
|
| |`|` |_logical-expression_ `||` _and-expression_
|
|
|
|=================================================
|
|
|
|
|
|
+
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|=======================================
|
|
|
|_and-expression_ |: |_relation_
|
|
|
| |`|` |_and-expression_ `&&` _relation_
|
|
|
|=======================================
|
|
|
|
|
|
+
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|==============================================================
|
|
|
|_relation_ |: |_logical-name_
|
|
|
| |`|` |`TRUE`
|
|
|
| |`|` |`FALSE`
|
|
|
| |`|` |_real-expression_ _relation-operator_ _real-expression_
|
|
|
|==============================================================
|
|
|
|
|
|
+
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|===============================
|
|
|
|_logical-name_ |: |_identifier_
|
|
|
|===============================
|
|
|
|
|
|
+
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|============================
|
|
|
|_relation-operator_ |: |`==`
|
|
|
| |`|` |`!=`
|
|
|
| |`|` |`<`
|
|
|
| |`|` |`>`
|
|
|
| |`|` |`>=`
|
|
|
| |`|` |`<=`
|
|
|
|============================
|
|
|
|
|
|
[[logical-variables]]
|
|
|
Logical variables:
|
|
|
~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|===========================
|
|
|
|_logical-prefix_ |: |`BOOL`
|
|
|
| |`|` |`BOOL CONST`
|
|
|
|===========================
|
|
|
|
|
|
+
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|=======================================================================
|
|
|
|_logical-definition_ |: |_logical-prefix_ _logical-name_ `=`
|
|
|
_logical-expression_
|
|
|
|
|
|
| | |*// expression evaluated*
|
|
|
|
|
|
| |`|` |_logical-prefix_ _logical-name `:=`_ _logical-expression_
|
|
|
|
|
|
| | |*// expression retained*
|
|
|
|=======================================================================
|
|
|
|
|
|
+
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|====
|
|
|
|====
|
|
|
|
|
|
[[string-expressions]]
|
|
|
String expressions:
|
|
|
~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|==========================================
|
|
|
|_string-expression_ |: |_string_
|
|
|
| |`|` |_identifier_ *// taken as a string*
|
|
|
| |`|` |_string-expression_ `&` _string_
|
|
|
|==========================================
|
|
|
|
|
|
[[string-constants]]
|
|
|
String constants:
|
|
|
~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|============================
|
|
|
|_string-prefix_ |: |`STRING`
|
|
|
|============================
|
|
|
|
|
|
+
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|=======================================================================
|
|
|
|_string-definition_ |: |_string-prefix_ _string-name_ `=`
|
|
|
_string-expression_
|
|
|
|
|
|
| | |*// expression evaluated*
|
|
|
|
|
|
| |`|` |_string-prefix_ _string-name_ `:=` _string-expression_
|
|
|
|
|
|
| | |*// expression retained*
|
|
|
|=======================================================================
|
|
|
|
|
|
[[real-array-expressions]]
|
|
|
Real array expressions:
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|==========================================
|
|
|
|_array-expression_ |: |_array-term_
|
|
|
| |`|` |`+` _array-term_
|
|
|
| |`|` |`-` _array-term_
|
|
|
| |`|` |_array-expression_ `+` _array-term_
|
|
|
| |`|` |_array-expression_ `-` _array-term_
|
|
|
|==========================================
|
|
|
|
|
|
+
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|======================================
|
|
|
|_array-term_ |: |_array-factor_
|
|
|
| |`|` |_array-term_ `*` _array-factor_
|
|
|
| |`|` |_array-term_ `/` _array-factor_
|
|
|
|======================================
|
|
|
|
|
|
+
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|=========================================
|
|
|
|_array-factor_ |: |_array-primary_
|
|
|
| |`|` |_array-factor_ `^` _array-primary_
|
|
|
|=========================================
|
|
|
|
|
|
+
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|=================================================
|
|
|
|_array-primary_ |: |`{` _array-literal_ `}`
|
|
|
| |`|` |_array-reference_
|
|
|
| |`|` |_real-function_ `(` _array-expression_ `)`
|
|
|
| |`|` |`(` _array-expression_ `)`
|
|
|
|=================================================
|
|
|
|
|
|
+
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|============================================
|
|
|
|_array-literal_ |: |_real-expression_
|
|
|
| |`|` |_array-literal_ `,` _real expression_
|
|
|
|============================================
|
|
|
|
|
|
+
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|===========================================
|
|
|
|_array-reference_ |: |_array-name_
|
|
|
| |`|` |_object-name_ `->` _array-attribute_
|
|
|
|===========================================
|
|
|
|
|
|
+
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|=============================
|
|
|
|_array-name_ |: |_identifier_
|
|
|
|=============================
|
|
|
|
|
|
[[real-array-definitions]]
|
|
|
Real array definitions:
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|================================
|
|
|
|_array-prefix_ |: |`REAL VECTOR`
|
|
|
|================================
|
|
|
|
|
|
+
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|=======================================================================
|
|
|
|_array-definition_ |: |_array-prefix_ _array-name_ `=`
|
|
|
_array-expression_
|
|
|
|
|
|
| |`|` |_array-prefix_ _array-name_ `:=` _array-expression_
|
|
|
|=======================================================================
|
|
|
|
|
|
+
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|====
|
|
|
|====
|
|
|
|
|
|
[[constraints]]
|
|
|
Constraints:
|
|
|
~~~~~~~~~~~~
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|=======================================================================
|
|
|
|_constraint_ |: |_array-expression_ _constraint-operator_
|
|
|
_array-expression_
|
|
|
|=======================================================================
|
|
|
|
|
|
+
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|==============================
|
|
|
|_constraint-operator_ |: |`==`
|
|
|
| |`|` |`<`
|
|
|
| |`|` |`>`
|
|
|
|==============================
|
|
|
|
|
|
[[variable-references]]
|
|
|
Variable references:
|
|
|
~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|==========================================
|
|
|
|_variable-reference_ |: |_real-name_
|
|
|
| |`|` |_object-name_ `->` _attribute-name_
|
|
|
|==========================================
|
|
|
|
|
|
[[token-lists]]
|
|
|
Token lists:
|
|
|
~~~~~~~~~~~~
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|========================================
|
|
|
|_token-list_ |: |_anything-except-comma_
|
|
|
|========================================
|
|
|
|
|
|
+
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|==========================================
|
|
|
|_token-list-array_ |: |_token-list_
|
|
|
| |`|` |_token-list-array_ `,` _token-list_
|
|
|
|==========================================
|
|
|
|
|
|
[[regular-expressions]]
|
|
|
Regular expressions:
|
|
|
~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
[cols="<,^,<",]
|
|
|
|==========================================================
|
|
|
|_regular-expression_ |: |`"`__UNIX-regular-expression__`"`
|
|
|
|========================================================== |