Die folgenden Regeln bilden formal die Grammatik, die die Sprache AZUR beschreibt. Bis zur Regel "const -> ..." finden sich solche, die kein Terminalsymbol produzieren, demnach auch kein Eingabesymbol verbrauchen, ab "ident -> ..." sind dann die Terminalproduktionen angegegben. Man beachte, dass die Grammatik nur den syntaktischen Aufbau der Sprache beschreibt. Weitergehende Definitionen zum Erstellen semantisch korrekter Programme sind im Kapitel Semantik aufgeführt.
azurprogram | -> | |
azurfunc | -> | |
parameters | -> | () | ( decllist ) | (ellipsis) |
decllist | -> | decl | decl , decllist | |
decl | -> | |
returntype | -> | : ident | e |
cmdlist | -> | command; | |
command | -> | forloop | whileloop | repeatloop | ifstmt |
|
forloop | -> | forall ident in expression cmdlist endfor |
whileloop | -> | while ( condition ); cmdlist endwhile |
repeatloop | -> | repeat; cmdlist until ( condition ) |
ifstmt | -> | if ( condition ); cmdlist elsebranch |
elsebranch | -> | endif | else; cmdlist endif | elseif ( condition ); cmdlist elsebranch |
assignment | -> | ident := expression | ident++ | ident -- | ident += expression | ident -= expression |
procedurecall | -> | ident paramlist |
paramlist | -> | () | ( exprlist ) |
returnstmt | -> | return expression |
exprlist | -> | expression | expression , exprlist |
condition | -> | monomlist | monomlist or condition |
monomlist | -> | monom | monom and monomlist |
monom | -> | expression cmpop expression |
|
cmpop | -> | = | # | < | > | <= | >= |
intervall | -> | [expression , expression] |
distanz | -> | ~ expression |
zp | -> | @ factor |
distanz | -> | ~ factor |
expression | -> | term | term addop expression |
term | -> | factor | factor mulop term | factor | -> | functioncall | const | ident | |
addop | -> | + | - |
mulop | -> | * | / | ^ |
functioncall | -> | ident paramlist |
const | -> | number | stringconst | ident |
ident | -> | _|$|a-z|A-Z [_|a-z|A-Z|0-9 [...] ] |
number | -> | NUMBER |
stringconst | -> | STRINGCONST |
bracketopen | -> | ( |
bracketclose | -> | ) |
braceopen | -> | [ |
braceclose | -> | ] |
scopeopen | -> | { |
scopeclose | -> | } |
Assignment | -> | := |
equal | -> | = |
smaller | -> | < |
greater | -> | > |
smallerequal | -> | <= |
greaterequal | -> | >= |
notequal | -> | # |
semicolon | -> | ; |
comma | -> | , |
colon | -> | : |
alpha | -> | @ |
tilde | -> | ~ |
ellipsis | -> | ... |
plus | -> | + |
minus | -> | - |
mult | -> | * |
div | -> | / |
tothepower | -> | ^ |
and | -> | AND |
or | -> | OR |
not | -> | NOT |
if | -> | IF |
else | -> | ELSE |
endif | -> | ENDIF |
forall | -> | FORALL |
in | -> | IN |
endfor | -> | ENDFOR |
while | -> | WHILE |
endwhile | -> | ENDWHILE |
repeat | -> | REPEAT |
until | -> | UNTIL |
return | -> | RETURN |
extern | -> | EXTERN |
uses | -> | USES |
end | -> | END |
arrayelement | -> | ident [ ident ] |
increment | -> | ident ++ |
decrement | -> | ident -- |
plusequal | -> | ident += expression |
minusequal | -> | ident -= expression |
mulequal | -> | ident *= expression |
divequal | -> | ident /= expression |
Increment | -> | ++ |
Decrement | -> | -- |
Plusequal | -> | += |
Minusequal | -> | -= |
Mulequal | -> | *= |
Divequal | -> | /= |
elseif | -> | ENDIF |
caseequal | -> | ~= |
constspec | -> | CONST |
Wie an der Regel "factor -> ..." zu erkennen, handelt es sich nicht um eine LR(2)-