Skip to content

LEO ​

LEO is a META language, which can be defined as a special form of concrete languages. This concrete language is used for the display of complex data structure values in a readable form. Furthermore, LEO offers also the possibility to use the (arithmetical) expressions. Moreover, this concrete language can contain Scripting elements.

LEO Syntax ​

The syntax of LEO is based on the following three main principles:

  • A LEOgramm is a sequence of elements. Every element starts with a keyword in capital letters. Everything that is executed until the next keyword, belongs to this element.
  • Elements have attributes, whose names start with a lower-case letter. Every attribute will be assigned a value or at least an implicit default value. For attributes there are different data types. The order in which the attribute belongs within an element is not important.
  • A value can be a literal of one of the LEO data types, this means a figure or a string or a calculated expression. In some cases an element or an attribute can be assigned to a LEOgramm.

A simplified description fo the structure of LEO commands is:

leo-grammar
Keyword { Modifier } [ MainParameter ] { AttributeParameter | Modifier } [ Body ]
# Note: the curly brackets above denote "zero or more" occurrences.

Keyword : UppercaseIdentifier .

Modifier : LowercaseIdentifier .

MainParameter : anyValue .

AttributeParameter : varName:anyValue .

Body : { StatementSequence } .
# Note: the curly brackets of the Body are needed (terminal symbols).
Keyword { Modifier } [ MainParameter ] { AttributeParameter | Modifier } [ Body ]
# Note: the curly brackets above denote "zero or more" occurrences.

Keyword : UppercaseIdentifier .

Modifier : LowercaseIdentifier .

MainParameter : anyValue .

AttributeParameter : varName:anyValue .

Body : { StatementSequence } .
# Note: the curly brackets of the Body are needed (terminal symbols).

At assignments of attributes the attribute name and the assigned value will be quoted together. The data type of an attribute can be text, figure or measure of length. A speciality are the expressions, which enable the calculation of values during the execution time. Furthermore you can also set modificators at an attribute which are attributes of the attributes.

Examples for attribute assignments:

firma:"BOC"
plz:1010
pos:right:20.4cm
color:blue
write-protected
e:(m \* c \* c)
firma:"BOC"
plz:1010
pos:right:20.4cm
color:blue
write-protected
e:(m \* c \* c)

The first attribute is of type text, the second of type figure. Concerning the third attribute it is a measure of length in cm as well as the modificator right, quoted.

The attribute colour will not be assigned to a value, but the modificator blue is set. Therefore modificators can also have an enumeration character.

Another feature is the fifth attribute write-protected, where its meaning depends on whether it is quoted or not. This way, in case of concrete languages it is possible to assign true values. The end builds here an attribute with an expression. These expressions are always in brackets and access the environment variables. The existing possibilities depend on the concrete language.

During the evaluation order, it is decided in the attributes of the evaluated program, if the order of the given attributes is of importance. Often, the attributes have default values, which are assigned to the attributes when they have not been filled in. If an undefined attribute is quoted, it will be ignored - as it could be a future extension or a deleted attribute. There can be many blanks and breaks between the attribute assignments.

A LEO element can also have a nameless attribute, where its value can be taken as the value of the element. If it is quoted, it stands directly behind the element name. Examples:

LEVEL 42
FRUIT "Gala" country:"Styria"
LEVEL 42
FRUIT "Gala" country:"Styria"

Between elements and between attributes there could be as many blanks and breaks as the user likes. A value of the data type text will be surrounded by the quotation marks and can contain as many characters as the user likes, but masking using the (/) is sometimes necessary. Numerical values must be quoted with the measure unit. Here the units m, cm, mm and pt are available, and should be used. As separation marks at flaoting-point numbers a decimal point has to be set. This is not necessary for values without a comma - therefore the user can e.g. write 1 instead of 1.0.

A detailed description of the syntax is provided further below.

LEO Comments

LEO allows for two different types of comments:

  • Line comments: Line comments in LEO start with a hash (#). Text after the hash until the end of the line is ignored.
  • Long comments: Long comments can span several lines. They start with (* and end with *).

Example:

asc
#--- Squirrel jam 4e4
(* begin *) SET t1:(getTickCount())
\# something is computed here
SET t2:(getTickCount()) (* end *)
SET sec:((t2 - t1) \* 0.001)
(* This comment is
a little bit longer
haha hey :-) *)
CC "AdoScript" INFOBOX "The computation took " + STR sec + " seconds."
#--- Squirrel jam 4e4
(* begin *) SET t1:(getTickCount())
\# something is computed here
SET t2:(getTickCount()) (* end *)
SET sec:((t2 - t1) \* 0.001)
(* This comment is
a little bit longer
haha hey :-) *)
CC "AdoScript" INFOBOX "The computation took " + STR sec + " seconds."

Only the following parts are regarded as code:

asc
SET t1:(getTickCount())
SET t2:(getTickCount())
SET sec:((t2 - t1) \* 0.001)
CC "AdoScript" INFOBOX "The computation took " + STR sec + " seconds."
SET t1:(getTickCount())
SET t2:(getTickCount())
SET sec:((t2 - t1) \* 0.001)
CC "AdoScript" INFOBOX "The computation took " + STR sec + " seconds."

Use of Expressions in LEO ​

In most cases values, which can be assigned to a specific attribute of a LEO element, are limited to a fixed data type. Besides the data types integer value, floating-point value, measure of length, time and string there is a datatype named expression in LEO.

An expression consists of values (numerical values, measure values, times, strings), variables and operators, or function calls. If no variables are contained it is a constant expression. As the result of a constant expression is always the same, a constant expression can be interpreted as a value. Thus a constant expression can be quoted everywhere in the LEOgram where a constant value is expected. This will be interpreted as if the result had been quoted directly.

Example for constant expressions:

leo
EXAMPLE "abcabc" x:5cm
EXAMPLE (2 * "abc") x:(2cm + 3cm)
EXAMPLE "abcabc" x:5cm
EXAMPLE (2 * "abc") x:(2cm + 3cm)

In the first element only constant values appear and in the second only constant expressions appear. Independent of the expression of the concrete language both elements are equivalent.

Variable expressions are used only in concrete languages for which they are intended (like AdoScript) - this means where there is a value of type Expression quoted. In languages where variable expressions appear, elements with which operation variables can be set. These operation variables are only visible in the program flow itself and can be used in all variable expressions. On positions where a variable expression can be quoted, a constant is allowed to be quoted.

Example for use of variable expressions:

leo
# Consider SET a command to sets the value of a variable.
SET text:"abc" y:10cm       # Setting values of variables text and y.
EXAMPLE (2 * text) x:(y / 2)
# Consider SET a command to sets the value of a variable.
SET text:"abc" y:10cm       # Setting values of variables text and y.
EXAMPLE (2 * text) x:(y / 2)

If the attribute value is quoted as an expression, it has to be written in brackets. Within an expression blanks and breaks can be used.

When and how often the evaluation of the expressions is made, depends on where the concrete language is used. Without expressions the LEOgramm represents a value of a determined data structure. A LEOgramm with expressions represents an amount of values of a determined data structure. The evaluation of the expressions leads to an element of this amount.

Hint

The available operators and functions that can be used in expressions are described in LEO Operators and Functions.

LEO Grammar ​

  • Terminal symbols are written in bold.
  • Non-terminal symbols are written in cursive.
  • The end of a "production rule" is indicated by a single dot . symbol.
  • Parts between square brackets [ ] are considered optional and can be used once (i.e. zero to one).
  • Parts between curly brackets { } are considered optional and are repeatable (i.e. zero to many).
  • Alternatives are separated by a vertical bar |.
  • Three dots ... are used as placeholders to be replaced appropriate to the meaning (e.g. number value ranges).
  • A boldly written Attention: is not a terminal symbol, but provides important information.
Non-terminalDefinition
LEO-Program :{ Element | IncludeDirective } .
Element :Keyword [ SimpleValueOrExpr ] { Attribute } [ Body ] .
Keyword :uc_identifier .
Attribute :AttrName [ : Modifier ] [ : SimpleValExprOrBody ] .
AttrName :attr_identifier | ArrayLValue .
ArrayLValue :lc_identifier [ CommaExpr ] .
Attention: the [ ] in ArrayLValue are terminal symbols!
Modifier :attr_identifier .
SimpleValExprOrBody :SimpleValueOrExpr | Body .
SimpleValueOrExpr :SimpleValue | ( CommaExpression ) .
CommaExpr :OrExpr | CommaExpr , OrExpr .
OrExpr :AndExpr | OrExpr OR AndExpr .
AndExpr :EqualityExpr | AndExpr AND EqualityExpr .
EqualityExpr :AddExpr [ EqualityOp AddExpr ] .
EqualityOp := | < | > | <> | != | <= | >= .
AddExpr :MultExpr | AddExpr + MultExpr | AddExpr - MultExpr .
MultExpr :UnaryExpr | MultExpr * UnaryExpr | MultExpr / UnaryExpr | MultExpr SUB UnaryExpr .
UnaryExpr :PostfixExpr | UnaryOp UnaryExpr .
UnaryOp :- | LEN | NOT | STR | VAL | CM | CMS | PT | PTS | ROUND | FLOOR | CEIL | INT | ASC | CHR .
PostfixExpr :PrimaryExpr | ArraySubscription | StructSubscription | FunctionCall .
ArraySubscription :PostfixExpr [ CommaExpr ] .
Attention: the [ ] in ArraySubscription are terminal symbols!
StructSubscription :PostfixExpr.lc_identifier .
Attention: the first . in StructSubscription is a terminal symbol!
FunctionCall :lc_identifier Parameters [ MoreParameters1 ] .
PrimaryExpr :Value | expr_identifier | ( CommaExpr ) .
Parameters :( ExpressionSeq ) .
MoreParameters1 :{ CommaExpr } { MoreParameters2 } .
Attention: the first { } in MoreParameters1 are terminal symbols!
MoreParameters2 :( CommaExpr ) | { CommaExpr } .
Attention: the { } in MoreParameters2 are terminal symbols!
ExpressionSeq :[ Expression { , Expression } ] .
Expression :OrExpr .
Value :SimpleValue | ArrayValue .
SimpleValue :NumValue | MeasureValue | TimeValue | StringValue .
MeasureValue :NumValue MeasureUnit .
TimeValue :LeoTimeValue AdoTimeValue .
LeoTimeValue :NumValue | TimeUnit .
NumValue :DecValue | HexValue .
DecValue :DecValue1 | DecValue2 .
DecValue1 :[ - ] intValue [ . digit { digit } ] [ Exponent ] [ % ] .
Attention: the first . in DecValue1 is a terminal symbol!
DecValue2 :[ - ] . digit { digit } [ Exponent ] [ % ] .
Attention: the first . in DecValue1 is a terminal symbol!
Exponent :e [ - ] digit { digit } .
HexValue :[ - ] $ { hexdigit } .
MeasureUnit :m | cm | mm | pt .
TimeUnit :s .
StringValue :"{ letter }" .
AdoTimeValue :years : days : hours : mins : secs .
years :intValue .
days :000 | ... | 365 .
hours :00 | ... | 24 .
mins, secs :00 | ... | 59 .
intValue :digit{ digit } .
ArrayValue :{ CommaExpr } .
Attention: the { } in ArrayValue are terminal symbols!
MapValue :{ MapValueContent } .
Attention: the { } in MapValue are terminal symbols!
MapValueContent :MapValuePair | MapValueContent , MapValuePair .
MapValuePair :OrExpr : OrExpr .
expr_identifier :lc_identifier | qm_identifier .
lc_identifier :lc_letter { lc_letter | uc_letter | digit } .
qm_identifier :? attr_identifier .
attr_identifier :lc_letter { lc_letter | uc_letter | digit | - } .
uc_identifier :uc_letter { uc_letter | _ } .
uc_letter :A | ... | Z .
lc_letter :a | ... | z .
hexdigit :digit | A | ... | F | a | ... | f .
digit :0 | ... | 9 .
Body :{ LEO-Program } .
Attention: the { } in Body are terminal symbols!
IncludeDirective :@INCLUDE Filename .
Filename :strValue .

Attention

Spaces are not considered in this syntax table. Sometimes they are required, sometimes they are not allowed. Identifiers and numeric values must not contain blanks. Inside of strings the character " has to be represented by \" and the character \ by \\. There are two types of comments in LEO. Line comments are introduced by the character # and apply to the rest of the current line. Long comments are beginning with (* and ending with *).