Skip to content

cwru-compilers/recursive

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Example Recursive Descent Parser

By Tim Henderson

Setup

$ git clone https://github.com/cwru-compilers/recursive.git
$ cd recursive
$ virtualenv --no-site-packages env
$ . env/bin/activate
$ pip install -r requirements.txt

Run the tests

$ nosetests

Notes

  1. The Lexer is handwritten and in lexer.py
  2. There are tests which can be run with nosetests

Grammar

Original

Expr   -> Expr PLUS Term
        | Expr DASH Term
Term   -> Term STAR Unary
        | Term SLASH Unary
Unary  -> DASH Factor
        | Factor
Factor -> NUMBER
        | LPAREN Expr RPAREN

LL(1)

Expr   -> Term Expr_
Expr_  -> PLUS Term Expr_
        | DASH Term Expr_
        | e
Term   -> Unary Term_
Term_  -> STAR Unary Term_
        | SLASH Unary Term_
        | e
Unary  -> DASH Factor
        | Factor
Factor -> NUMBER
        | LPAREN Expr RPAREN

About

A demonstration recursive descent parser.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages