Miniproject.


The first section of the course Programming Language Implementation and Formalisation, is about programming. In particular, we have learned some advanced programming techniques that are commonly used in interpreter and compiler implementations.

In this assignment, you are asked to write a parser for the Boa programming langauge, using the monadic combinator library for constructing parsers called Parsec.

Credits


The Boa programming language was designed by Andrzej Filinski, and this project is based on two weekly assignments from the course Advanced Programming, where Andrzej is course responsible at the time of writing.

Grammar of Boa.

In Oblig 1, we introduced the abstract syntax of Boa, and we wrote an interpreter for it. The concrete syntax of Boa is given by the following grammar, written in EBNF form:

Program     ::= Statements
Statements  ::= Statement
              | Statement ';' Statements
Statement   ::= ident '=' Expr
              | Expr
Expr        ::= numConst
              | stringConst
              | 'None' | 'True' | 'False'
              | ident
              | Expr Oper Expr
              | 'not' Expr
              | '(' Expr ')'
              | ident '(' Exprz ')'
              | '[' Exprz ']'
              | '[' Expr ForClause Clausez ']'
Oper        ::= '+'  | '-'  | '*' | '//' | '%'
              | '==' | '!=' | '<' | '<=' | '>' | '>='
              | 'in' | 'not' 'in'
ForClause   ::= 'for' ident 'in' Expr
IfClause    ::= 'if' Expr
Clausez     ::= eps
              | ForClause Clausez
              | IfClause  Clausez
Exprz       ::= eps
              | Exprs
Exprs       ::= Expr
              | Expr ',' Exprs
ident       ::= (see text)
numConst    ::= (see text)
stringConst ::= (see text)

In naming the nonterminals, we use the informal mnemonic convention that a Foos is a sequence containing at least one Foo, whereas a Fooz sequence may also be of length zero. Supplementing the formal grammar, we also specify the following:

What to hand in

Code

Please fill in the blanks, in the handed out stack project. That is, any function which is undefined should be defined by you.

Report

Your handin should include a short (1--2 pages) report. In your report, we want you to address the following