Skip to content

helvm/while-lang-interpreter

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Small interpreter in Haskell

The main objective of this mini project is to make our hands dirty with the Haskell programming language and to make use of some functional programming features to build a very simple interpreter for the While language. (Problem link)

For simplicity, all terminals will be separated by blanks to avoid problems while lexing.

Below is the description of grammar that we will use.

Arithmetic operators precedence: (*, /) >> (+, -)

Logical operators precedence: (and) >> (or)

Comparison operators precedence: (>, <)

Statment      ::= var := ArithExp StatmentAux
                | if BoolExp then { Statment } else { Statment } StatmentAux
                | while BoolExp do { Statment } StatmentAux

StatmentAux   ::= ; Statment
                | epsilon

BoolExp       ::= BoolTerm BoolExpAux

BoolExpAux    ::= or BoolTerm BoolExpAux
                | epsilon

BoolTerm      ::= BoolFactor BoolTermAux

BoolTermAux   ::= and BoolFactor BoolTermAux
                | epsilon

BoolFactor    ::= true
                | false
                | ( BoolExp )
                | ArithComp

ArithComp     ::= ArithExp ArithCompAux

ArithCompAux  ::= > ArithExp
                | < ArithExp

ArithExp      ::= Term ArithExpAux

ArithExpAux   ::= + Term ArithExpAux
                | - Term ArithExpAux
                | epsilon

Term          ::= Factor TermAux

TermAux       ::= * Factor TermAux
                | / Factor TermAux
                | epsilon

Factor        ::= var
                | int
                | ( ArithExp )

About

No description or website provided.

Topics

Resources

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published

Languages

  • Haskell 100.0%