Skip to content
flofreud edited this page Apr 22, 2013 · 25 revisions

Document Status: Draft / Work in Progress

This article is a draft and work in progress. Feel free to comment and discuss on the issue tracker.

Remarks

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)

Grammar rules

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*

basic -> long | double | string | bool

string -> " (.*) " //?? escaping?

id -> ...

Note: *...* marks terminals

terminal definition

digit -> [0-9]
digits -> digit+
integralDigits -> -? digits
exponent -> ((e | E) integralDigits)
num -> digits 
real -> digits . digits exponent? | digits exponent
basic -> (long | double | string | bool)
alpha -> [a-zA-Z]
alphaNumeric -> [a-zA-Z0-9]
id -> alpha alphaNumeric*

Semantic

Definition of semantic of each term (if necessary)

Clone this wiki locally