Language Reference

Introduction

This document is the primary reference for the Event programming language. It describes each language construct.

This document does not serve as an introduction to the language itself.

Input format

Event is interpreted as a sequence of ASCII characters. Every statement has to be closed with a semicolon (;).

Statements are marked with the tag Stamement across this document.

The following keywords are forbidden to use as identifiers and types:

The top level input sequence are statements terminated with a semicolon (;).

Comments

Comments in Event follow the C89 style comments. Starting with /* and ending with */.

<code>
/* commented out block /*
<code>

Whitespaces

The interpretation of Event allows to use the following list of whitespaces:

Identifiers

Identifiers are defined as follows:

Example:

anIdentifier_42

Types

Types for Event are defined as follows:

Example:

AType_23

Numbers

Event handles numbers of the type double as defined by the used operating system. They are defined as follows:

Example:

42
1.337

Vectors

Vectors are defined as a list of numbers, separated by commas and can only contain numbers as a result of a given expression. The list is encapsulated by square brackets ([]).

Example:

[42]
[1, 2, 1 + 2]

It is not possible to stack vectors into other vectors.

Comparisons

In Event, you can only compare vectors. The following comparisons are possible:

Example:

event1.pos == event2.pos
event1.time > event2.time

Operations

Like comparisons, operation can also operate only on vectors. Following operations are possible, based on vector math:

Example:

event.pos + [1, 2, 3]
[1, 2] - [3, 4]
6 * event.time

Inside a vector as a member more mathematical operations are possible. Every member operation is an expression which has to result in number. The following operations are possible:

Multiplication and division have precedence over addition and difference. Parenthesis (()) are possible to change the precedence.

Example:

1 + 1
4 - 3
2 * 7
13 / 3
-42
(1 + 2) * 3

Events

Statement

Events are containers for related information. One event can extend another one by using the keyword extends. The event declaration has the following structure:

The third part and the fourth part are optional for event inheritance.

The following parts are mandatory and define a comma separated list of event members holding the actual information and are encapsulated by curly braces ({}).

Example:

event SampleEvent { position, time };
event RangeEvent extends SampleEvent { range };

For inheritance, only new members are allowed to be added in the inherited event. It is forbidden to declare the same member in both, the event and it's inheritance.

To define an event with content, you enclose the information with curly braces.

The following is a comma separated list:

Example:

{
    position = event_a.position + event_b.position,
    time = event_a.time + [1.34]
}

Predicates

Statement

Predicates are operating on events passed to them. They return either False or True. The return value is generated by the comparison applied to the predicate. A predicate has to take at least on event as an argument. The expression assigned to the predicate has to be a single comparison as described above. Predicates are created as below:

Arguments are a comma separated list of tuples made out of a type and an identifier. Arguments are defined as follows:

Back to the argument list.

To separate the predicate definition from it's comparison expression, "define" (:=) is used.

Example:

predicate a_predicate(SampleEvent e) := e.position == [1, 1, 1];
predicate b_predicate(SampleEvent e, RangeEvent r) := e.position != r.position;

Functions

Statement

Functions are also operating on events passed to them. A function must have a return type. Functions are created as follows:

Arguments are a comma separated list of tuples made out of a type and an identifier and optional. Arguments are defined as follows:

Back to the argument list.

To separate the function definition from it's expression block, "define" (:=) is used.

An expression can be one of the following:

Example:

SampleEvent function_a(SampleEvent event_a) := {
    position = event_a.position + [1, 0, 0],
    time = 6 * event_a.time
}

SampleEvent function_b(SampleEvent e) := function_a(e);

Rules

Rules take a list of event types, a list of predicates and a call function.

The following is optional:

The following is optional:

The following is mandatory:

Example:

RuleA: [SampleEvent : a_predicate] -> function_b;