Add "And" and "Or"
This commit is contained in:
parent
0085a91251
commit
8fc21a0988
@ -10,6 +10,14 @@ let rec string_of_ty = function
|
||||
let s2 = string_of_ty t2 in
|
||||
"(" ^ s1 ^ " -> " ^ s2 ^ ")"
|
||||
| Bot -> "False"
|
||||
| And(t1, t2) ->
|
||||
let s1 = string_of_ty t1 in
|
||||
let s2 = string_of_ty t2 in
|
||||
"(" ^ s1 ^ " /\\ " ^ s2 ^ ")"
|
||||
| Or(t1, t2) ->
|
||||
let s1 = string_of_ty t1 in
|
||||
let s2 = string_of_ty t2 in
|
||||
"(" ^ s1 ^ " \\/ " ^ s2 ^ ")"
|
||||
|
||||
let rec string_of_expr = function
|
||||
Fun ((s, t), e) ->
|
||||
|
@ -27,6 +27,8 @@ rule token = parse
|
||||
| "->" { TARR }
|
||||
| '~' { TILDE }
|
||||
| "exf" { EXFALSO }
|
||||
| "/\\" { AND }
|
||||
| "\\/" { OR }
|
||||
|
||||
| "Goal" { GOAL }
|
||||
| "exact" { EXACT }
|
||||
|
@ -9,6 +9,7 @@ open Parser_entry
|
||||
%token PLUS TIMES
|
||||
%token TOP BOT EXFALSO TILDE
|
||||
%token LPAREN RPAREN
|
||||
%token AND OR
|
||||
%token FUN ARR COLON TARR
|
||||
%token <string> VARID
|
||||
%token <string> TYID
|
||||
@ -19,6 +20,8 @@ open Parser_entry
|
||||
|
||||
%right TARR
|
||||
%right TILDE
|
||||
%right AND
|
||||
%right OR
|
||||
|
||||
%start main
|
||||
%type <parser_entry> main
|
||||
@ -50,6 +53,8 @@ ty:
|
||||
| BOT { Bot }
|
||||
| LPAREN t=ty RPAREN { t }
|
||||
| TILDE t=ty { Arr(t, Bot) }
|
||||
| t1=ty AND t2=ty { And(t1, t2) }
|
||||
| t1=ty OR t2=ty { Or(t1, t2) }
|
||||
| t1=ty TARR t2=ty { Arr(t1, t2) }
|
||||
|
||||
expression:
|
||||
|
Loading…
Reference in New Issue
Block a user