This repository has been archived on 2024-01-18. You can view files and clone it, but cannot push or open issues or pull requests.
compilation/tp/tp-menhir/code/parser.mly

32 lines
259 B
OCaml
Raw Normal View History

2023-10-02 09:39:12 +02:00
%{ (* Emacs, open this with -*- tuareg -*- *)
open AST
%}
%token<int> INT
%token<string> ID
%token PLUS EOF
%start<AST.exp> phrase
%left PLUS
%%
phrase: e=exp EOF
{
e
}
exp: x=INT
{
LInt x
}
| x=ID
{
Id x
}
| e1=exp PLUS e2=exp
{
Add (e1, e2)
}