Difference between revisions of "Prokee Module: bmc"
| Line 65: | Line 65: | ||
To refer to an element within a block, the '.' operator can be used similar to most object oriented languages. | To refer to an element within a block, the '.' operator can be used similar to most object oriented languages. | ||
| − | F.e. if we want to know the height of the rectangle above, we could write <code>Rectangle.Height</code> . | + | F.e. if we want to know the height of the rectangle above, we could write <code>Rectangle.Height</code>. |
Revision as of 22:26, 30 April 2019
The program bmc is an experimental compiler for dbl code which is a small subset of the Universal Prokee Language (UPL).
Block Syntax
The concept of Named Blocks is taken from UPL. An named block is given by its name followed by the blocks contents within curly braces. Empty named blocks are called Words.
Words are Literals which are defined by just stating them, followed by either the empty block {} or a semicolon. To define the Word "Vienna" we can write Vienna; or Vienna{}.
Blocks allow the definition of additional named blocks (or words) within the block.
F.e. the following example lists some districts of Vienna.
Vienna
{
Kagran;
Brigittenau;
Leopoldstadt;
...
}
Such blocks can be nested to model more complex structures.
Additionally each block may contain one or more values. The only type of supported values are strings. The following example shows a definition of a rectangle, where the dimensions are given as the values of the blocks Width and Height.
Rectangle
{
Width
{
"10 cm"
}
Height
{
"7 cm"
}
}
To reduce typing a bit, bmc allows to compact the example above to a more natural looking equivalent variation.
Rectangle
{
Width="10 cm";
Height="7 cm";
}
Inheritance
Blocks may inherit properties from other blocks. Inheritance is established by the ':' operator.
To illustrate this, the next example shows the definition of an point and a rectangle, which inherits its position from the point.
Point
{
Horizontal-Position="10 cm";
Vertical-Position="10 cm";
}
Rectangle:Point
{
Width="10 cm";
Height="7 cm";
}
The DEF keyword is used to overwrite inherited properties.
In the following example Rectangle has the dimensions 10 x 7 cm.
StandardRectangle
{
Width="10 cm";
Height="10 cm";
}
Rectangle:StandardRectangle
{
DEF Height="7 cm";
}
To refer to an element within a block, the '.' operator can be used similar to most object oriented languages.
F.e. if we want to know the height of the rectangle above, we could write Rectangle.Height.