Source file template_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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
module MenhirBasics = struct
exception Error
let _eRR =
fun _s ->
raise Error
type token =
| TEXT of
# 15 "lib/template_parser.mly"
(string)
# 15 "lib/template_parser.ml"
| IDEN of
# 14 "lib/template_parser.mly"
(string)
# 20 "lib/template_parser.ml"
| EOF
end
include MenhirBasics
# 1 "lib/template_parser.mly"
open Template_ast
let merge_consec_text_nodes ast =
List.fold_left
(fun acc node ->
match acc, node with
| Text prev :: tl, Text s -> Text (prev ^ s) :: tl
| _ -> node :: acc)
[] ast
|> List.rev
# 41 "lib/template_parser.ml"
type ('s, 'r) _menhir_state =
| MenhirState0 : ('s, _menhir_box_template) _menhir_state
(** State 0.
Stack shape : <empty>.
Start symbol: template. *)
| MenhirState6 : (('s, _menhir_box_template) _menhir_cell1_ast_nodes, _menhir_box_template) _menhir_state
(** State 6.
Stack shape : ast_nodes.
Start symbol: template. *)
and ('s, 'r) _menhir_cell1_ast_nodes =
| MenhirCell1_ast_nodes of 's * ('s, 'r) _menhir_state * (Template_ast.ast_node)
and _menhir_box_template =
| MenhirBox_template of (Template_ast.ast) [@@unboxed]
let _menhir_action_1 =
fun i ->
(
# 25 "lib/template_parser.mly"
( Iden i )
# 66 "lib/template_parser.ml"
: (Template_ast.ast_node))
let _menhir_action_2 =
fun t ->
(
# 26 "lib/template_parser.mly"
( Text t )
# 74 "lib/template_parser.ml"
: (Template_ast.ast_node))
let _menhir_action_3 =
fun () ->
(
# 216 "<standard.mly>"
( [] )
# 82 "lib/template_parser.ml"
: (Template_ast.ast_node list))
let _menhir_action_4 =
fun x xs ->
(
# 219 "<standard.mly>"
( x :: xs )
# 90 "lib/template_parser.ml"
: (Template_ast.ast_node list))
let _menhir_action_5 =
fun ast ->
(
# 22 "lib/template_parser.mly"
( merge_consec_text_nodes ast )
# 98 "lib/template_parser.ml"
: (Template_ast.ast))
let _menhir_print_token : token -> string =
fun _tok ->
match _tok with
| TEXT _ ->
"TEXT"
| IDEN _ ->
"IDEN"
| EOF ->
"EOF"
let _menhir_fail : unit -> 'a =
fun () ->
Printf.eprintf "Internal failure -- please contact the parser generator's developers.\n%!";
assert false
include struct
[@@@ocaml.warning "-4-37"]
let _menhir_run_4 : type ttv_stack. ttv_stack -> _ -> _menhir_box_template =
fun _menhir_stack _v ->
let ast = _v in
let _v = _menhir_action_5 ast in
MenhirBox_template _v
let rec _menhir_run_7 : type ttv_stack. (ttv_stack, _menhir_box_template) _menhir_cell1_ast_nodes -> _ -> _menhir_box_template =
fun _menhir_stack _v ->
let MenhirCell1_ast_nodes (_menhir_stack, _menhir_s, x) = _menhir_stack in
let xs = _v in
let _v = _menhir_action_4 x xs in
_menhir_goto_list_ast_nodes_ _menhir_stack _v _menhir_s
and _menhir_goto_list_ast_nodes_ : type ttv_stack. ttv_stack -> _ -> (ttv_stack, _menhir_box_template) _menhir_state -> _menhir_box_template =
fun _menhir_stack _v _menhir_s ->
match _menhir_s with
| MenhirState0 ->
_menhir_run_4 _menhir_stack _v
| MenhirState6 ->
_menhir_run_7 _menhir_stack _v
let rec _menhir_run_1 : type ttv_stack. ttv_stack -> _ -> _ -> _ -> (ttv_stack, _menhir_box_template) _menhir_state -> _menhir_box_template =
fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s ->
let _tok = _menhir_lexer _menhir_lexbuf in
let t = _v in
let _v = _menhir_action_2 t in
_menhir_goto_ast_nodes _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok
and _menhir_goto_ast_nodes : type ttv_stack. ttv_stack -> _ -> _ -> _ -> (ttv_stack, _menhir_box_template) _menhir_state -> _ -> _menhir_box_template =
fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok ->
let _menhir_stack = MenhirCell1_ast_nodes (_menhir_stack, _menhir_s, _v) in
match (_tok : MenhirBasics.token) with
| TEXT _v_0 ->
_menhir_run_1 _menhir_stack _menhir_lexbuf _menhir_lexer _v_0 MenhirState6
| IDEN _v_1 ->
_menhir_run_2 _menhir_stack _menhir_lexbuf _menhir_lexer _v_1 MenhirState6
| EOF ->
let _v_2 = _menhir_action_3 () in
_menhir_run_7 _menhir_stack _v_2
and _menhir_run_2 : type ttv_stack. ttv_stack -> _ -> _ -> _ -> (ttv_stack, _menhir_box_template) _menhir_state -> _menhir_box_template =
fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s ->
let _tok = _menhir_lexer _menhir_lexbuf in
let i = _v in
let _v = _menhir_action_1 i in
_menhir_goto_ast_nodes _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok
let _menhir_run_0 : type ttv_stack. ttv_stack -> _ -> _ -> _menhir_box_template =
fun _menhir_stack _menhir_lexbuf _menhir_lexer ->
let _tok = _menhir_lexer _menhir_lexbuf in
match (_tok : MenhirBasics.token) with
| TEXT _v ->
_menhir_run_1 _menhir_stack _menhir_lexbuf _menhir_lexer _v MenhirState0
| IDEN _v ->
_menhir_run_2 _menhir_stack _menhir_lexbuf _menhir_lexer _v MenhirState0
| EOF ->
let _v = _menhir_action_3 () in
_menhir_run_4 _menhir_stack _v
end
let template =
fun _menhir_lexer _menhir_lexbuf ->
let _menhir_stack = () in
let MenhirBox_template v = _menhir_run_0 _menhir_stack _menhir_lexbuf _menhir_lexer in
v