-
Notifications
You must be signed in to change notification settings - Fork 0
Grammar
Tkrauss edited this page Apr 19, 2013
·
25 revisions
This article is a draft and work in progress. Feel free to comment and discuss on the issue tracker.
Several questions have to be addressed:
- What is the definition of "id“, "num", "basic", "real" und "string"?
- What is the semantic of "if (assign)" for "assign" -> "loc = assign"?
- The grammar is ambiguous for "if else" (Dangling Else). How to solve it (prioritoes)?
- What is the difference between "id" and "loc.id" for "loc"?
- What is the semantic for "break" outside of a loop?
(Author: Sven, Translator: Flo)
The provided grammmar can be found here: https://github.com/swp-uebersetzerbau-ss13/common/blob/master/doc/quellsprache.pdf?raw=true
program -> decls stmts
block -> {decls stmts}
decls -> decls decl | ϵ
decl -> type *id*;
type -> type [*num*] | *basic* | *record* {decls}
stmts -> stmts stmt | ϵ
stmt -> assign;
| *if*(assign) stmt
| *if*( assign ) stmt *else* stmt
| *while*( assign ) stmt
| *do* stmt *while* ( assign );
| *break*;
| *return*;
| *return* loc;
| *print* loc;
| block
loc -> loc [assign] | *id* | loc.*id*
assign -> loc=assign | bool
bool -> bool||join | join
join -> join&&equality | equality
equality -> equality==rel | equality!=rel | rel
rel -> expr<expr | expr<=expr | expr>=expr | expr>expr | expr
expr -> expr+term | expr-term | term
term -> term*unary | term/unary | unary
unary -> !unary | -unary | factor
factor -> (assign) | loc | *num* | *real* | *true* | *false* | *string*
Note: *...* marks terminals
Definition of semantic of each term (if necessary)