pieuvre/parser.mly

69 lines
1.5 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-04-09 11:09:33 +02:00
%token <string> VARID
%token <string> TYID
2024-04-30 11:44:28 +02:00
%token GOAL EXACT ASSUMPTION INTRO CUT APPLY
2024-04-09 11:09:33 +02:00
%token EOL
2024-04-15 12:07:49 +02:00
2024-04-16 10:07:09 +02:00
%right TARR
%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-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) }
| INTRO { Tact (Intro) }
| 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) }
| 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 }