-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparser.ml
165 lines (149 loc) · 4.1 KB
/
parser.ml
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
153
154
155
156
157
158
159
160
161
162
163
164
165
type token =
| LPAREN
| RPAREN
| STERM
| KTERM
| ITERM
| LET
| IN
| EQUALS
| EOF
| VAR of (string)
open Parsing;;
let _ = parse_error;;
# 1 "parser.mly"
open Ast
open Printf
open Lexing
let merge (fn,pos1,_) (_,_,pos2) = (fn,pos1,pos2)
# 23 "parser.ml"
let yytransl_const = [|
257 (* LPAREN *);
258 (* RPAREN *);
259 (* STERM *);
260 (* KTERM *);
261 (* ITERM *);
262 (* LET *);
263 (* IN *);
264 (* EQUALS *);
0 (* EOF *);
0|]
let yytransl_block = [|
265 (* VAR *);
0|]
let yylhs = "\255\255\
\001\000\001\000\001\000\001\000\001\000\002\000\002\000\000\000"
let yylen = "\002\000\
\001\000\001\000\001\000\004\000\001\000\002\000\006\000\002\000"
let yydefred = "\000\000\
\000\000\000\000\000\000\001\000\002\000\003\000\000\000\005\000\
\000\000\008\000\000\000\000\000\006\000\000\000\000\000\004\000\
\000\000\000\000\007\000"
let yydgoto = "\002\000\
\009\000\010\000"
let yysindex = "\001\000\
\000\255\000\000\010\255\000\000\000\000\000\000\254\254\000\000\
\010\000\000\000\010\255\008\255\000\000\015\255\010\255\000\000\
\011\255\000\255\000\000"
let yyrindex = "\000\000\
\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
\000\000\000\000\000\000"
let yygindex = "\000\000\
\253\255\002\000"
let yytablesize = 20
let yytable = "\011\000\
\003\000\001\000\004\000\005\000\006\000\007\000\012\000\014\000\
\008\000\013\000\003\000\017\000\004\000\005\000\006\000\015\000\
\016\000\018\000\008\000\019\000"
let yycheck = "\003\000\
\001\001\001\000\003\001\004\001\005\001\006\001\009\001\011\000\
\009\001\000\000\001\001\015\000\003\001\004\001\005\001\008\001\
\002\001\007\001\009\001\018\000"
let yynames_const = "\
LPAREN\000\
RPAREN\000\
STERM\000\
KTERM\000\
ITERM\000\
LET\000\
IN\000\
EQUALS\000\
EOF\000\
"
let yynames_block = "\
VAR\000\
"
let yyact = [|
(fun _ -> failwith "parser")
; (fun __caml_parser_env ->
Obj.repr(
# 23 "parser.mly"
( S )
# 100 "parser.ml"
: Ast.ski))
; (fun __caml_parser_env ->
Obj.repr(
# 24 "parser.mly"
( K )
# 106 "parser.ml"
: Ast.ski))
; (fun __caml_parser_env ->
Obj.repr(
# 25 "parser.mly"
( I )
# 112 "parser.ml"
: Ast.ski))
; (fun __caml_parser_env ->
let _2 = (Parsing.peek_val __caml_parser_env 2 : Ast.ski) in
let _3 = (Parsing.peek_val __caml_parser_env 1 : Ast.ski) in
Obj.repr(
# 26 "parser.mly"
( Term(_2, _3) )
# 120 "parser.ml"
: Ast.ski))
; (fun __caml_parser_env ->
let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in
Obj.repr(
# 27 "parser.mly"
( Var(_1) )
# 127 "parser.ml"
: Ast.ski))
; (fun __caml_parser_env ->
let _1 = (Parsing.peek_val __caml_parser_env 1 : Ast.ski) in
Obj.repr(
# 30 "parser.mly"
( Ski(_1) )
# 134 "parser.ml"
: Ast.program))
; (fun __caml_parser_env ->
let _2 = (Parsing.peek_val __caml_parser_env 4 : string) in
let _4 = (Parsing.peek_val __caml_parser_env 2 : Ast.ski) in
let _6 = (Parsing.peek_val __caml_parser_env 0 : Ast.program) in
Obj.repr(
# 31 "parser.mly"
( Let(_2,_4,_6) )
# 143 "parser.ml"
: Ast.program))
(* Entry p *)
; (fun __caml_parser_env -> raise (Parsing.YYexit (Parsing.peek_val __caml_parser_env 0)))
|]
let yytables =
{ Parsing.actions=yyact;
Parsing.transl_const=yytransl_const;
Parsing.transl_block=yytransl_block;
Parsing.lhs=yylhs;
Parsing.len=yylen;
Parsing.defred=yydefred;
Parsing.dgoto=yydgoto;
Parsing.sindex=yysindex;
Parsing.rindex=yyrindex;
Parsing.gindex=yygindex;
Parsing.tablesize=yytablesize;
Parsing.table=yytable;
Parsing.check=yycheck;
Parsing.error_function=parse_error;
Parsing.names_const=yynames_const;
Parsing.names_block=yynames_block }
let p (lexfun : Lexing.lexbuf -> token) (lexbuf : Lexing.lexbuf) =
(Parsing.yyparse yytables 1 lexfun lexbuf : Ast.program)