Skip to content

Latest commit

 

History

History
56 lines (37 loc) · 1.24 KB

grammar.md

File metadata and controls

56 lines (37 loc) · 1.24 KB

#BasicDSP 2.0

Grammar Definition

program → statement-list EOF

statement-list → statement statement-list
statement-list → EMPTY

statement → assignment (LF | CR | SEMICOLON)

assignment → IDENT '=' expr

expr → expr + term
expr → expr - term
expr → term

term → term * factor
term → term / factor
term → factor

factor → FUNCTION '(' expr ')'
factor → '(' expr ')'
factor → - factor
factor → INTEGER
factor → FLOAT
factor → IDENT

Grammar with left recursion removed

program → statement-list EOF

statement-list → statement statement-list
statement-list → EMPTY

statement → assignment (LF | CR | SEMICOLON)

assignment → IDENT '=' expr

expr → term expr'
expr' → - term expr' | + term expr' | e

term → factor term'
term' → * factor term' | / factor term' | e

factor → FUNCTION '(' expr ')'
factor → '(' expr ')'
factor → - factor
factor → INTEGER
factor → FLOAT
factor → IDENT

more information about grammars

Compiler patterns