Notation

Reserved words and built-in identifers appear in bold. Examples would be TREE or CALC.

Punctuation tokens appear in quotes. Examples would be ‘{‘ or ‘}’ or ‘(‘ or ‘)’

Language Specification / Grammar

To Iterate Is Human, To Recurse Divine - Peter Deutsch

compilationUnit:
def+

def:
TREE nodePath ‘{’ nodeInfo* ‘}’ |
CALC nodePath ‘{’ resultDef* ‘}’ |
INPUT id ( ‘{’ resultDef* ‘}’ | ‘;’ ) |
FUNC resultDef |
TABLE id ‘(’ colNames ‘)’ ’{’ tableLine* ‘}

nodeInfo:
NODE nodeName ( AS id )? nodeInclusion? nodeTimes? ( ‘;’ | ‘{’ nodeInfo* ‘}’ ) |
LINK linkPath ‘;

nodeInclusion:
IF formula

nodeTimes:
TIMES formula AS id

resultDef:
id arguments? ‘=’ formula ‘;

arguments:
(’ id ( ‘,’ id )* ‘)

id:
<ID> |
keywordAsId

keywordAsId:
AS | TABLE | TREE | CALC | INPUT | FUNC | NODE | IF | THEN | ELSE | ENDIF | CASE | WHEN | DEFAULT | ENDCASE | collate | extract | sumx | prodx | vectorx | cell | cellx | exists | interpol | tabcols | tabrows | lookup | lookupx | lookdownx | funcref | docall | counterlist

constantOrId:
constant | id

tableLine:
tableCell ( ‘,’ tableCell )* ‘;’

tableCell:
constant | id

nodenName:
constant | id

nodePath:
id ( ‘.’ id )*

linkPath:
id ( ‘.’ linkPart )*

linkPart:
id | <STRING> | ‘*’ | ‘**’

colNames:
colName ( ‘,’ colName )*

colName:
id | <NUMBER> | <STRING>

vpmsFormula:
formula <EOF>

formula:
formula2 ( ‘?’ formula2 ‘:’ formula2 )*

formula2:
formula3 ( ‘||’ formula3 )*

formula3:
formula4 ( ‘&&’ formula4 )*

formula4:
formula5 ( ‘XOR’ formula5 )*

formula5:
formula6 ( comparisonOperator formula6 )*

formula6:
formula7 ( ‘&’ formula7 )*

formula7:
formula8 ( ( ‘+’ | ‘-‘ ) formula8 )*

formula8:
formula9 ( ( ‘’ | ‘/’ | ‘DIV’ | ‘MOD’ ) formula9 )

formula9:
formula10 ( ‘^’ formula9 )?

formula10:
( ‘+’ | ‘-‘ )* expression

expression:
‘(‘ formula ‘)’ |
sumx ‘(‘ id ‘,’ formula ‘,’ formula ‘,’ formula ‘)’ |
prodx ‘(‘ id ‘,’ formula ‘,’ formula ‘,’ formula ‘)’ |
vectorx ‘(‘ id ‘,’ formula ‘,’ formula ‘,’ formula ‘)’ |
collate ‘(‘ id ( ‘(‘ formula ( ‘,’ formula )* ‘)’ )? ‘)’ |
extract ‘(‘ id ( ‘(‘ formula ( ‘,’ formula )* ‘)’ )? ‘,’ formula ‘)’ |
cell ‘(‘ tableRef ‘,’ range ‘,’ range ‘)’ |
cellx ‘(‘ tableRef ‘,’ range ‘,’ range ‘)’ |
lookup ‘(‘ tableRef ‘,’ formula ‘)’ |
lookupx ‘(‘ tableRef ‘,’ formula ( ‘,’ formula )* ‘)’ |
lookdownx ‘(‘ tableRef ‘,’ formula ( ‘,’ formula )* ‘)’ |
exists ‘(‘ tableRef ‘,’ formula ( ‘,’ formula )* ‘)’ |
interpol ‘(‘ tableRef ‘,’ formula ‘)’ |
tabcols ‘(‘ tableRef ‘)’ |
tabrows ‘(‘ tableRef ‘)’ |
funcref ‘(‘ formula ‘)’ |
docall ‘(‘ formula ( ‘,’ formula )* ‘)’ |
counterlist ‘(‘ id ( ‘,’ id )* ‘)’ |
<ID> |
<ID> ‘.’ id |
<ID> index columnAccess? |
dynTable ( index columnAccess? )? |
<ID> parameterListe |
ifStmt |
caseStmt |
constant

tableRef:
id | dynTable

range:
formula ( ‘..’ formula )?

ifStmt:
IF formula THEN formula ELSE formula ENDIF

caseStmt:
CASE formula caseWhen* caseDefault? ENDCASE

caseWhen:
WHEN caseCompares ‘:’ formula

caseCompares:
caseCompare ( ‘,’ caseCompare )*

caseCompare:
caseConstant |
caseConstantNumber ‘..’ caseConstantNumber |
<STRING> ‘..’ <STRING>

caseDefault:
DEFAULT ‘:’ formula

caseConstant:
<STRING> | caseConstantNumber

caseConstantNumber:
<NUMBER> | ‘-<NUMBER>

dynTable:
tabref(’ formula ‘)

columnAccess:
.’ id | ‘(’ formula ‘)

comparisonOperator:
‘=’ | ‘==’ | ‘<’ | ‘>’ | ‘<=’ | ‘>=’ | ‘<>’ | ‘!=’ | ‘s=’ | ‘s<>’ | ‘si=’ | ‘si<>’ | ‘s<’ | ‘s>=’ | ‘si<’ | ‘si>=’ | ‘s>’ | ‘s<=’ | ‘si>’ | ‘si<=’

parameterListe:
(’ ( formula ( ‘,’ formula )* )? ‘)

index:
[’ formula ( ‘,’ formula )* ‘]

constant:
<STRING> | <NUMBER>

Edit Me! This website is a public GitHub repo. Please help by forking the project and adding to it.