-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathparser.mly
More file actions
36 lines (34 loc) · 719 Bytes
/
parser.mly
File metadata and controls
36 lines (34 loc) · 719 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
%{
open Term
%}
%token <string> IDENT
%token EOF
%token LPAREN RPAREN
%token ARROW EQUIV AND OR NOT BOT TOP
%token STRAY
%nonassoc EQUIV
%right ARROW
%right OR
%right AND
%nonassoc NOT
%start main
%type <Term.pnterm> main
%type <Term.pnterm> expression
%%
main:
| expression EOF { $1 }
expression:
| IDENT { PNVarName $1 }
| LPAREN expression RPAREN { $2 }
| expression EQUIV expression {
let t1 = $1 in
let t2 = $3 in
PNAnd (PNArrow (t1,t2),PNArrow (t2,t1))
}
| expression ARROW expression { PNArrow ($1,$3) }
| expression OR expression { PNOr ($1,$3) }
| expression AND expression { PNAnd ($1,$3) }
| NOT expression { PNArrow ($2,PNBot) }
| TOP { PNTop }
| BOT { PNBot }
;