-
Notifications
You must be signed in to change notification settings - Fork 0
/
parser.mly
152 lines (120 loc) · 3.59 KB
/
parser.mly
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
%{
module Concrete = Smt2d.Concrete
%}
%token EOF
%token OPEN CLOSE
%token <string> NUMERAL DECIMAL HEXADECIMAL BINARY STRING SYMBOL OTHER_KEYWORD
%token UNDERSCORE
%token AS
%token LET FORALL EXISTS ATTRIBUTE
%token CLAUSES CONCLUSION
%start step
%type <Proof.step> step
%%
numeral_plus:
| NUMERAL { [$1] }
| NUMERAL numeral_plus { $1 :: $2 }
;
symbol_plus:
| SYMBOL { [$1] }
| SYMBOL symbol_plus { $1 :: $2 }
;
keyword:
| CLAUSES { ":clauses" }
| CONCLUSION { ":conclusion" }
| OTHER_KEYWORD { $1 }
;
spec_constant:
| NUMERAL { Concrete.Numeral $1 }
| DECIMAL { Concrete.Decimal $1 }
| HEXADECIMAL { Concrete.Hexadecimal $1 }
| BINARY { Concrete.Binary $1 }
| STRING { Concrete.String $1 }
;
s_expr:
| spec_constant { Concrete.Spec_constant_expr $1 }
| SYMBOL { Concrete.Symbol_expr $1 }
| keyword { Concrete.Keyword_expr $1 }
| OPEN s_expr_star CLOSE { Concrete.List_expr $2 }
;
s_expr_star:
| { [] }
| s_expr s_expr_star { $1 :: $2 }
;
identifier:
| SYMBOL { ($1,[]) }
| OPEN UNDERSCORE SYMBOL numeral_plus CLOSE { ($3,$4) }
;
sort:
| identifier { Concrete.parse_sort $1 [] }
| OPEN identifier sort_plus CLOSE { Concrete.parse_sort $2 $3 }
;
sort_plus:
| sort { [$1] }
| sort sort_plus { $1 :: $2 }
;
attribute_value:
| spec_constant { Concrete.Spec_constant_value $1 }
| SYMBOL { Concrete.Symbol_value $1 }
| OPEN s_expr_star CLOSE { Concrete.S_expr_list_value $2 }
;
attribute:
| keyword { ($1,None) }
| keyword attribute_value { ($1,Some $2) }
;
attribute_plus:
| attribute { [$1] }
| attribute attribute_plus { $1 :: $2 }
;
qual_identifier:
| identifier { ($1,None) }
| OPEN AS identifier sort CLOSE { ($3,Some $4) }
;
var_binding:
| OPEN SYMBOL term CLOSE { ($2,$3) }
;
var_binding_plus:
| var_binding { [$1] }
| var_binding var_binding_plus { $1 :: $2 }
;
sorted_var:
| OPEN SYMBOL sort CLOSE { ($2,$3) }
;
sorted_var_plus:
| sorted_var { [$1] }
| sorted_var sorted_var_plus { $1 :: $2 }
;
term:
| spec_constant { Concrete.Spec_constant_term $1 }
| qual_identifier { Concrete.parse_fun $1 [] }
| OPEN qual_identifier term_plus CLOSE { Concrete.parse_fun $2 $3 }
| OPEN LET OPEN var_binding_plus CLOSE term CLOSE { Concrete.Let_term ($4,$6) }
| OPEN FORALL OPEN sorted_var_plus CLOSE term CLOSE { Concrete.Forall_term ($4,$6) }
| OPEN EXISTS OPEN sorted_var_plus CLOSE term CLOSE { Concrete.Exists_term ($4,$6) }
| OPEN ATTRIBUTE term attribute_plus CLOSE { Concrete.Attributed_term ($3,$4) }
;
term_star:
| { [] }
| term term_star { $1 :: $2 }
;
term_plus:
| term { [$1] }
| term term_plus { $1 :: $2 }
;
clauses:
| { [] }
| CLAUSES OPEN symbol_plus CLOSE { $3 }
;
conclusion:
| CONCLUSION OPEN term_star CLOSE { $3 }
;
step:
| OPEN SYMBOL SYMBOL OPEN SYMBOL clauses conclusion CLOSE CLOSE
{ { Proof.id = $3;
Proof.rule = Proof.mk_rule $5;
Proof.clauses = $6;
Proof.conclusion =
List.map (Smt2d.Abstract.mk_term Smt2d.Abstract.empty_vars) $7; } }
| EOF { raise End_of_file }
;
%%