The Siddhi Language consists of following constructs.
- Event Definitions
- Queries
- Calls to external functions (not supported in 1.0)
Following provides an abstract BNF based definition for Siddhi language.
<query> ::= <define-stream> | <execution-query>
<define-stream> ::= define stream <stream-name> <attribute-name> <type> {<attribute-name> <type>}
<execution-query>::= <input> <output> [<projection>]
<input> ::= from <streams>
<output> ::= ((insert [<output-type>] into <stream-name>) | (return [<output-type>]))
<streams> ::= <stream>[#<window>]
| <stream>#<window> [unidirectional] <join> [unidirectional] <stream>#<window> on <condition> within <time>
| [every] <stream> -> <stream> ... <stream> within <time>
| <stream>, <stream>, <stream> within <time>
<stream> ::= <stream-name> <condition-list>
<projection> ::= (<external-call> <attributelist>) | <attributelist> [group by <attribute-name> ][having <condition>]
<external-call> ::= call <name> ( <param-list> )
<condition-list> ::= {‘[’<condition>’]’}
<attributelist>::=(<attribute-name> [as <reference-name>]) | ( <function>(<param-list>) as <reference-name>)
<output-type> ::= expired-events | current-events | all-events
<param-list> ::= {<expression>}
<condition> ::= ( <condition> (and|or) <condition> ) | (not <condition>) | ( <expression> (==|!=|>=|<=|>|<|contains|instanceof) <expression> )
<expression> ::= ( <expression> (+ | - | / | * | %) <expression> ) | <attribute-name> | <int> | <long> | <double> | <float> | <string> | <time>
<time> ::= [<int>( years | year )] [<int>( months | month )] [<int>( weeks | week )] [<int>( days | day )] [<int>( hours | hour )] [<int>( minutes | min | minute )] [<int>( seconds | second | sec )]
[<int>( milliseconds | millisecond )]