LARA

Concrete Syntax of While Language

program ::= statement*
statement ::= print | assign | if | while | block
print ::= "println" "(" STRLIT "," var ")" ";"
assign ::= var "=" expr ";"
if ::= "if" "(" exp ")" statement ("else" statement)?
while ::= "while" "(" expr ")" statement
block ::= "{" statement* "}"
expr ::= var | INTLIT | expr binOp expr | unOp expr | "(" expr ")"
unOp ::= "!" | "-"
binOp ::= "+" | "-" | "*" | "/" | "%" | "==" | ">" | "<" | "&&" | "||"

Where “INTLIT” corresponds to literals recognized by (0|[1-9][0-9]*) and “STRLIT” to a string containing any visible character, except for “"” and new lines.

Example programs:

    • does the program terminate?
    • compiler does certain forms of reasoning about programs, this program shows this is in general difficult