Parser for dedepython+


I have provided a lexer and parser for dedepython+ on github.

Your task is to modify my lexer and parser to recognize a small language described in Lecture 3.

           add1 ( ‹expr› )
           sub1 ( ‹expr› )

Your parser should produce an abstract syntax as shown in Lecture 3 as well:

type expr =
  | Num of int64
  | Add1 of expr
  | Sub1 of expr

Example code

There's sample code in github. To run it you will need menhir and dune installed. I used opam to install mine.

You can parse a sample depython program using:

$ dune build
$ dune exec ./main.exe tests/112.dp
Module [
Expr Num 112

After modifying the lexer and parser you should be able to parse a program like the examples in lecture 3.



You should turn in your modified lexer.mll, parser.mly, and You shouldn't need to make changes to other files.