pieuvre/parser.mly

79 lines
1.8 KiB
OCaml
Raw Normal View History

2024-04-09 11:09:33 +02:00
%{
2024-04-16 10:07:09 +02:00
open Lam
2024-04-15 12:07:49 +02:00
open Types
2024-04-30 11:44:28 +02:00
open Proof
open Parser_entry
2024-04-09 11:09:33 +02:00
%}
2024-04-30 11:44:28 +02:00
%token DOT
2024-04-09 11:09:33 +02:00
%token PLUS TIMES
2024-04-16 10:07:09 +02:00
%token TOP BOT EXFALSO TILDE
2024-04-09 11:09:33 +02:00
%token LPAREN RPAREN
2024-04-16 10:07:09 +02:00
%token FUN ARR COLON TARR
2024-05-05 20:45:55 +02:00
%token AND OR
2024-04-09 11:09:33 +02:00
%token <string> VARID
%token <string> TYID
2024-05-11 11:44:43 +02:00
%token GOAL UNDO EXACT ASSUMPTION INTRO INTROS CUT APPLY
2024-05-06 10:09:40 +02:00
%token LEFT RIGHT SPLIT
2024-04-30 11:44:28 +02:00
2024-04-09 11:09:33 +02:00
%token EOL
2024-05-05 20:45:55 +02:00
%right TARR
2024-05-06 10:12:24 +02:00
%right OR
%right AND
2024-05-05 20:45:55 +02:00
%right TILDE
2024-04-15 12:07:49 +02:00
2024-04-09 11:09:33 +02:00
%start main
2024-04-30 11:44:28 +02:00
%type <parser_entry> main
2024-04-09 11:09:33 +02:00
%%
main:
2024-04-30 11:44:28 +02:00
| e=expression EOL { Lam e }
| t=tactic EOL { Cmd t }
tactic:
| c=command DOT { c }
command:
| GOAL t=ty { Goal t }
2024-05-11 11:44:43 +02:00
| UNDO { Undo }
2024-04-30 11:58:29 +02:00
| EXACT e=expression { Tact (Exact_term e) }
| EXACT s=TYID { Tact (Exact_proof s) }
2024-04-30 11:44:28 +02:00
| ASSUMPTION { Tact (Assumption) }
2024-05-01 10:44:36 +02:00
| INTROS { Tact (Intros) }
2024-04-30 11:44:28 +02:00
| INTRO { Tact (Intro) }
2024-05-06 10:09:40 +02:00
| SPLIT { Tact (Split) }
2024-05-05 20:45:55 +02:00
| RIGHT { Tact (Right) }
| LEFT { Tact (Left) }
2024-04-30 11:44:28 +02:00
| CUT t=ty { Tact (Cut t) }
| APPLY s=TYID { Tact (Apply s) }
2024-04-09 11:09:33 +02:00
ty_annot:
| id=VARID COLON t=ty { (id, t) }
2024-04-15 12:07:49 +02:00
ty:
| id=TYID { TVar(id) }
2024-04-16 10:07:09 +02:00
| BOT { Bot }
2024-04-15 12:07:49 +02:00
| LPAREN t=ty RPAREN { t }
2024-04-16 10:07:09 +02:00
| TILDE t=ty { Arr(t, Bot) }
2024-05-05 20:33:39 +02:00
| t1=ty AND t2=ty { And(t1, t2) }
| t1=ty OR t2=ty { Or(t1, t2) }
2024-04-16 10:07:09 +02:00
| t1=ty TARR t2=ty { Arr(t1, t2) }
2024-04-15 12:07:49 +02:00
2024-04-09 11:09:33 +02:00
expression:
| FUN LPAREN annot=ty_annot RPAREN ARR e=expression
{ Fun (annot, e) }
2024-04-16 10:07:09 +02:00
| EXFALSO LPAREN e=expression COLON t=ty RPAREN
{ Exf (e, t) }
2024-04-09 11:09:33 +02:00
| e=app_expr { e }
app_expr:
| e=app_expr a=atomic { App (e, a) }
| a=atomic { a }
atomic:
| id=VARID { Var id }
| LPAREN e=expression RPAREN
{ e }