Source file mustache_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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737

module MenhirBasics = struct
  
  exception Error
  
  let _eRR =
    fun _s ->
      raise Error
  
  type token = 
    | UNESCAPE of (
# 83 "mustache/lib/mustache_parser.mly"
       (string list)
# 15 "mustache/lib/mustache_parser.ml"
  )
    | RAW of (
# 92 "mustache/lib/mustache_parser.mly"
       (string)
# 20 "mustache/lib/mustache_parser.ml"
  )
    | PARTIAL of (
# 86 "mustache/lib/mustache_parser.mly"
       (int * string)
# 25 "mustache/lib/mustache_parser.ml"
  )
    | OPEN_SECTION of (
# 85 "mustache/lib/mustache_parser.mly"
       (string list)
# 30 "mustache/lib/mustache_parser.ml"
  )
    | OPEN_PARTIAL_WITH_PARAMS of (
# 87 "mustache/lib/mustache_parser.mly"
       (int * string)
# 35 "mustache/lib/mustache_parser.ml"
  )
    | OPEN_PARAM of (
# 88 "mustache/lib/mustache_parser.mly"
       (int * string)
# 40 "mustache/lib/mustache_parser.ml"
  )
    | OPEN_INVERTED_SECTION of (
# 84 "mustache/lib/mustache_parser.mly"
       (string list)
# 45 "mustache/lib/mustache_parser.ml"
  )
    | ESCAPE of (
# 82 "mustache/lib/mustache_parser.mly"
       (string list)
# 50 "mustache/lib/mustache_parser.ml"
  )
    | EOF
    | COMMENT of (
# 90 "mustache/lib/mustache_parser.mly"
       (string)
# 56 "mustache/lib/mustache_parser.ml"
  )
    | CLOSE of (
# 89 "mustache/lib/mustache_parser.mly"
       (string)
# 61 "mustache/lib/mustache_parser.ml"
  )
  
end

include MenhirBasics

# 23 "mustache/lib/mustache_parser.mly"
  
  open Mustache_types
  open Mustache_types.Ast

  let mkloc (start_pos, end_pos) =
    { loc_start = start_pos;
      loc_end = end_pos }

  let check_matching loc name_kind start_name end_name =
    if start_name <> end_name then
      raise (Mismatched_names (mkloc loc, { name_kind; start_name; end_name }))

  let dotted name =
    string_of_dotted_name name

  let with_loc loc desc =
    { loc = mkloc loc; desc }


  (* The template-inheritance specification describes partial-with-params
     application of the form:

     {{<foo}}
       text here is ignored
       {{$param1}}default value{{/param1}}
       ignored again
       {{$param2}}default value{{/param2}}
       still ignored
     {{/foo}}

    It is weird that content that is not a template parameter is simply
    ignored inside the partial invocation. For raw content, this is
    explicitly mandated by the specification. For non-parameter tags, we
    error.

    Some Mustache implementations support using a {{>foo}} partial if it itself
    expands to parameter blocks, but this is not specified in the implementation,
    slightly more work to implement (we have to defer parameter-filtering to
    the rendering step), and of dubious utility in practice, so for now we do
    not support this.
  *)
  let partial_parameters partial_name partial_block =
      let rec collect params_rev elt =
         match elt.desc with
         | Param param -> param :: params_rev
         | Comment _ | String _ ->
             (* the specification mandates that raw strings are inogred *)
             params_rev
         | (Escaped _ | Unescaped _ | Section _ | Inverted_section _ | Partial _) ->
            raise (Invalid_as_partial_parameter (partial_name, elt))
         | Concat elts ->
            List.fold_left collect params_rev elts
      in
      collect [] partial_block
      |> List.rev


# 126 "mustache/lib/mustache_parser.ml"

type ('s, 'r) _menhir_state = 
  | MenhirState00 : ('s, _menhir_box_mustache) _menhir_state
    (** State 00.
        Stack shape : .
        Start symbol: mustache. *)

  | MenhirState04 : (('s, _menhir_box_mustache) _menhir_cell1_OPEN_SECTION, _menhir_box_mustache) _menhir_state
    (** State 04.
        Stack shape : OPEN_SECTION.
        Start symbol: mustache. *)

  | MenhirState05 : (('s, _menhir_box_mustache) _menhir_cell1_OPEN_PARTIAL_WITH_PARAMS, _menhir_box_mustache) _menhir_state
    (** State 05.
        Stack shape : OPEN_PARTIAL_WITH_PARAMS.
        Start symbol: mustache. *)

  | MenhirState06 : (('s, _menhir_box_mustache) _menhir_cell1_OPEN_PARAM, _menhir_box_mustache) _menhir_state
    (** State 06.
        Stack shape : OPEN_PARAM.
        Start symbol: mustache. *)

  | MenhirState07 : (('s, _menhir_box_mustache) _menhir_cell1_OPEN_INVERTED_SECTION, _menhir_box_mustache) _menhir_state
    (** State 07.
        Stack shape : OPEN_INVERTED_SECTION.
        Start symbol: mustache. *)

  | MenhirState12 : (('s, _menhir_box_mustache) _menhir_cell1_mustache_element, _menhir_box_mustache) _menhir_state
    (** State 12.
        Stack shape : mustache_element.
        Start symbol: mustache. *)


and ('s, 'r) _menhir_cell1_mustache_element = 
  | MenhirCell1_mustache_element of 's * ('s, 'r) _menhir_state * (Mustache_types.Ast.t) * Lexing.position

and ('s, 'r) _menhir_cell1_OPEN_INVERTED_SECTION = 
  | MenhirCell1_OPEN_INVERTED_SECTION of 's * ('s, 'r) _menhir_state * (
# 84 "mustache/lib/mustache_parser.mly"
       (string list)
# 167 "mustache/lib/mustache_parser.ml"
) * Lexing.position

and ('s, 'r) _menhir_cell1_OPEN_PARAM = 
  | MenhirCell1_OPEN_PARAM of 's * ('s, 'r) _menhir_state * (
# 88 "mustache/lib/mustache_parser.mly"
       (int * string)
# 174 "mustache/lib/mustache_parser.ml"
) * Lexing.position

and ('s, 'r) _menhir_cell1_OPEN_PARTIAL_WITH_PARAMS = 
  | MenhirCell1_OPEN_PARTIAL_WITH_PARAMS of 's * ('s, 'r) _menhir_state * (
# 87 "mustache/lib/mustache_parser.mly"
       (int * string)
# 181 "mustache/lib/mustache_parser.ml"
) * Lexing.position

and ('s, 'r) _menhir_cell1_OPEN_SECTION = 
  | MenhirCell1_OPEN_SECTION of 's * ('s, 'r) _menhir_state * (
# 85 "mustache/lib/mustache_parser.mly"
       (string list)
# 188 "mustache/lib/mustache_parser.ml"
) * Lexing.position

and _menhir_box_mustache = 
  | MenhirBox_mustache of (Mustache_types.Ast.t) [@@unboxed]

let _menhir_action_01 =
  fun () ->
    (
# 216 "<standard.mly>"
    ( [] )
# 199 "mustache/lib/mustache_parser.ml"
     : (Mustache_types.Ast.t list))

let _menhir_action_02 =
  fun x xs ->
    (
# 219 "<standard.mly>"
    ( x :: xs )
# 207 "mustache/lib/mustache_parser.ml"
     : (Mustache_types.Ast.t list))

let _menhir_action_03 =
  fun mexpr ->
    (
# 153 "mustache/lib/mustache_parser.mly"
                              ( mexpr )
# 215 "mustache/lib/mustache_parser.ml"
     : (Mustache_types.Ast.t))

let _menhir_action_04 =
  fun _endpos_elt_ _startpos_elt_ elt ->
    let _endpos = _endpos_elt_ in
    let _symbolstartpos = _startpos_elt_ in
    let _sloc = (_symbolstartpos, _endpos) in
    (
# 100 "mustache/lib/mustache_parser.mly"
                 ( with_loc _sloc (Escaped elt) )
# 226 "mustache/lib/mustache_parser.ml"
     : (Mustache_types.Ast.t))

let _menhir_action_05 =
  fun _endpos_elt_ _startpos_elt_ elt ->
    let _endpos = _endpos_elt_ in
    let _symbolstartpos = _startpos_elt_ in
    let _sloc = (_symbolstartpos, _endpos) in
    (
# 101 "mustache/lib/mustache_parser.mly"
                   ( with_loc _sloc (Unescaped elt) )
# 237 "mustache/lib/mustache_parser.ml"
     : (Mustache_types.Ast.t))

let _menhir_action_06 =
  fun _endpos_end_name_ _startpos_start_name_ contents end_name start_name ->
    let _endpos = _endpos_end_name_ in
    let _symbolstartpos = _startpos_start_name_ in
    let _sloc = (_symbolstartpos, _endpos) in
    (
# 104 "mustache/lib/mustache_parser.mly"
                     (
      check_matching _sloc Section_name (dotted start_name) end_name;
      with_loc _sloc
        (Section { name = start_name; contents })
  )
# 252 "mustache/lib/mustache_parser.ml"
     : (Mustache_types.Ast.t))

let _menhir_action_07 =
  fun _endpos_end_name_ _startpos_start_name_ contents end_name start_name ->
    let _endpos = _endpos_end_name_ in
    let _symbolstartpos = _startpos_start_name_ in
    let _sloc = (_symbolstartpos, _endpos) in
    (
# 111 "mustache/lib/mustache_parser.mly"
                     (
      check_matching _sloc Inverted_section_name (dotted start_name) end_name;
      with_loc _sloc
        (Inverted_section { name = start_name; contents })
  )
# 267 "mustache/lib/mustache_parser.ml"
     : (Mustache_types.Ast.t))

let _menhir_action_08 =
  fun _endpos_partial_ _startpos_partial_ partial ->
    let _endpos = _endpos_partial_ in
    let _symbolstartpos = _startpos_partial_ in
    let _sloc = (_symbolstartpos, _endpos) in
    (
# 116 "mustache/lib/mustache_parser.mly"
                      (
      let (indent, name) = partial in
      with_loc _sloc
        (Partial { indent; name; params = None;
                   contents = lazy None })
  )
# 283 "mustache/lib/mustache_parser.ml"
     : (Mustache_types.Ast.t))

let _menhir_action_09 =
  fun _endpos_end_name_ _startpos_partial_ end_name partial partial_block ->
    let _endpos = _endpos_end_name_ in
    let _symbolstartpos = _startpos_partial_ in
    let _sloc = (_symbolstartpos, _endpos) in
    (
# 124 "mustache/lib/mustache_parser.mly"
                     (
      let (indent, start_name) = partial in
      check_matching _sloc Partial_with_params_name start_name end_name;
      let params = partial_parameters start_name partial_block in
      with_loc _sloc
        (Partial { indent; name = start_name; params = Some params;
                   contents = lazy None })
  )
# 301 "mustache/lib/mustache_parser.ml"
     : (Mustache_types.Ast.t))

let _menhir_action_10 =
  fun _endpos_end_name_ _startpos_param_ contents end_name param ->
    let _endpos = _endpos_end_name_ in
    let _symbolstartpos = _startpos_param_ in
    let _sloc = (_symbolstartpos, _endpos) in
    (
# 134 "mustache/lib/mustache_parser.mly"
                     (
      let (indent, start_name) = param in
      check_matching _sloc Param_name start_name end_name;
      with_loc _sloc
        (Param { indent; name = start_name; contents })
  )
# 317 "mustache/lib/mustache_parser.ml"
     : (Mustache_types.Ast.t))

let _menhir_action_11 =
  fun _endpos_s_ _startpos_s_ s ->
    let _endpos = _endpos_s_ in
    let _symbolstartpos = _startpos_s_ in
    let _sloc = (_symbolstartpos, _endpos) in
    (
# 140 "mustache/lib/mustache_parser.mly"
                ( with_loc _sloc (Comment s) )
# 328 "mustache/lib/mustache_parser.ml"
     : (Mustache_types.Ast.t))

let _menhir_action_12 =
  fun _endpos_s_ _startpos_s_ s ->
    let _endpos = _endpos_s_ in
    let _symbolstartpos = _startpos_s_ in
    let _sloc = (_symbolstartpos, _endpos) in
    (
# 141 "mustache/lib/mustache_parser.mly"
            ( with_loc _sloc (String s) )
# 339 "mustache/lib/mustache_parser.ml"
     : (Mustache_types.Ast.t))

let _menhir_action_13 =
  fun _endpos_elts_ _startpos_elts_ elts ->
    let _endpos = _endpos_elts_ in
    let _symbolstartpos = if _startpos_elts_ != _endpos_elts_ then
      _startpos_elts_
    else
      _endpos in
    let _sloc = (_symbolstartpos, _endpos) in
    (
# 144 "mustache/lib/mustache_parser.mly"
                                  (
    match elts with
    | [] -> with_loc _sloc (String "")
    | [x] -> x
    | xs -> with_loc _sloc (Concat xs)
  )
# 358 "mustache/lib/mustache_parser.ml"
     : (Mustache_types.Ast.t))

let _menhir_print_token : token -> string =
  fun _tok ->
    match _tok with
    | CLOSE _ ->
        "CLOSE"
    | COMMENT _ ->
        "COMMENT"
    | EOF ->
        "EOF"
    | ESCAPE _ ->
        "ESCAPE"
    | OPEN_INVERTED_SECTION _ ->
        "OPEN_INVERTED_SECTION"
    | OPEN_PARAM _ ->
        "OPEN_PARAM"
    | OPEN_PARTIAL_WITH_PARAMS _ ->
        "OPEN_PARTIAL_WITH_PARAMS"
    | OPEN_SECTION _ ->
        "OPEN_SECTION"
    | PARTIAL _ ->
        "PARTIAL"
    | RAW _ ->
        "RAW"
    | UNESCAPE _ ->
        "UNESCAPE"

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_21 : type  ttv_stack. ttv_stack -> _ -> _ -> _menhir_box_mustache =
    fun _menhir_stack _v _tok ->
      match (_tok : MenhirBasics.token) with
      | EOF ->
          let mexpr = _v in
          let _v = _menhir_action_03 mexpr in
          MenhirBox_mustache _v
      | _ ->
          _eRR ()
  
  let rec _menhir_run_01 : type  ttv_stack. ttv_stack -> _ -> _ -> _ -> (ttv_stack, _menhir_box_mustache) _menhir_state -> _menhir_box_mustache =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s ->
      let _startpos = _menhir_lexbuf.Lexing.lex_start_p in
      let _endpos = _menhir_lexbuf.Lexing.lex_curr_p in
      let _tok = _menhir_lexer _menhir_lexbuf in
      let (_endpos_elt_, _startpos_elt_, elt) = (_endpos, _startpos, _v) in
      let _v = _menhir_action_05 _endpos_elt_ _startpos_elt_ elt in
      _menhir_goto_mustache_element _menhir_stack _menhir_lexbuf _menhir_lexer _endpos _startpos_elt_ _v _menhir_s _tok
  
  and _menhir_goto_mustache_element : type  ttv_stack. ttv_stack -> _ -> _ -> _ -> _ -> _ -> (ttv_stack, _menhir_box_mustache) _menhir_state -> _ -> _menhir_box_mustache =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _endpos _startpos _v _menhir_s _tok ->
      let _menhir_stack = MenhirCell1_mustache_element (_menhir_stack, _menhir_s, _v, _startpos) in
      match (_tok : MenhirBasics.token) with
      | UNESCAPE _v_0 ->
          _menhir_run_01 _menhir_stack _menhir_lexbuf _menhir_lexer _v_0 MenhirState12
      | RAW _v_1 ->
          _menhir_run_02 _menhir_stack _menhir_lexbuf _menhir_lexer _v_1 MenhirState12
      | PARTIAL _v_2 ->
          _menhir_run_03 _menhir_stack _menhir_lexbuf _menhir_lexer _v_2 MenhirState12
      | OPEN_SECTION _v_3 ->
          _menhir_run_04 _menhir_stack _menhir_lexbuf _menhir_lexer _v_3 MenhirState12
      | OPEN_PARTIAL_WITH_PARAMS _v_4 ->
          _menhir_run_05 _menhir_stack _menhir_lexbuf _menhir_lexer _v_4 MenhirState12
      | OPEN_PARAM _v_5 ->
          _menhir_run_06 _menhir_stack _menhir_lexbuf _menhir_lexer _v_5 MenhirState12
      | OPEN_INVERTED_SECTION _v_6 ->
          _menhir_run_07 _menhir_stack _menhir_lexbuf _menhir_lexer _v_6 MenhirState12
      | ESCAPE _v_7 ->
          _menhir_run_08 _menhir_stack _menhir_lexbuf _menhir_lexer _v_7 MenhirState12
      | COMMENT _v_8 ->
          _menhir_run_09 _menhir_stack _menhir_lexbuf _menhir_lexer _v_8 MenhirState12
      | CLOSE _ | EOF ->
          let _v_9 = _menhir_action_01 () in
          _menhir_run_13 _menhir_stack _menhir_lexbuf _menhir_lexer _endpos _v_9 _tok
  
  and _menhir_run_02 : type  ttv_stack. ttv_stack -> _ -> _ -> _ -> (ttv_stack, _menhir_box_mustache) _menhir_state -> _menhir_box_mustache =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s ->
      let _startpos = _menhir_lexbuf.Lexing.lex_start_p in
      let _endpos = _menhir_lexbuf.Lexing.lex_curr_p in
      let _tok = _menhir_lexer _menhir_lexbuf in
      let (_endpos_s_, _startpos_s_, s) = (_endpos, _startpos, _v) in
      let _v = _menhir_action_12 _endpos_s_ _startpos_s_ s in
      _menhir_goto_mustache_element _menhir_stack _menhir_lexbuf _menhir_lexer _endpos _startpos_s_ _v _menhir_s _tok
  
  and _menhir_run_03 : type  ttv_stack. ttv_stack -> _ -> _ -> _ -> (ttv_stack, _menhir_box_mustache) _menhir_state -> _menhir_box_mustache =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s ->
      let _startpos = _menhir_lexbuf.Lexing.lex_start_p in
      let _endpos = _menhir_lexbuf.Lexing.lex_curr_p in
      let _tok = _menhir_lexer _menhir_lexbuf in
      let (_endpos_partial_, _startpos_partial_, partial) = (_endpos, _startpos, _v) in
      let _v = _menhir_action_08 _endpos_partial_ _startpos_partial_ partial in
      _menhir_goto_mustache_element _menhir_stack _menhir_lexbuf _menhir_lexer _endpos _startpos_partial_ _v _menhir_s _tok
  
  and _menhir_run_04 : type  ttv_stack. ttv_stack -> _ -> _ -> _ -> (ttv_stack, _menhir_box_mustache) _menhir_state -> _menhir_box_mustache =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s ->
      let _startpos = _menhir_lexbuf.Lexing.lex_start_p in
      let _endpos = _menhir_lexbuf.Lexing.lex_curr_p in
      let _menhir_stack = MenhirCell1_OPEN_SECTION (_menhir_stack, _menhir_s, _v, _startpos) in
      let _tok = _menhir_lexer _menhir_lexbuf in
      match (_tok : MenhirBasics.token) with
      | UNESCAPE _v_0 ->
          _menhir_run_01 _menhir_stack _menhir_lexbuf _menhir_lexer _v_0 MenhirState04
      | RAW _v_1 ->
          _menhir_run_02 _menhir_stack _menhir_lexbuf _menhir_lexer _v_1 MenhirState04
      | PARTIAL _v_2 ->
          _menhir_run_03 _menhir_stack _menhir_lexbuf _menhir_lexer _v_2 MenhirState04
      | OPEN_SECTION _v_3 ->
          _menhir_run_04 _menhir_stack _menhir_lexbuf _menhir_lexer _v_3 MenhirState04
      | OPEN_PARTIAL_WITH_PARAMS _v_4 ->
          _menhir_run_05 _menhir_stack _menhir_lexbuf _menhir_lexer _v_4 MenhirState04
      | OPEN_PARAM _v_5 ->
          _menhir_run_06 _menhir_stack _menhir_lexbuf _menhir_lexer _v_5 MenhirState04
      | OPEN_INVERTED_SECTION _v_6 ->
          _menhir_run_07 _menhir_stack _menhir_lexbuf _menhir_lexer _v_6 MenhirState04
      | ESCAPE _v_7 ->
          _menhir_run_08 _menhir_stack _menhir_lexbuf _menhir_lexer _v_7 MenhirState04
      | COMMENT _v_8 ->
          _menhir_run_09 _menhir_stack _menhir_lexbuf _menhir_lexer _v_8 MenhirState04
      | CLOSE _ ->
          let _v_9 = _menhir_action_01 () in
          _menhir_run_14 _menhir_stack _menhir_lexbuf _menhir_lexer _endpos _endpos _v_9 MenhirState04 _tok
      | _ ->
          _eRR ()
  
  and _menhir_run_05 : type  ttv_stack. ttv_stack -> _ -> _ -> _ -> (ttv_stack, _menhir_box_mustache) _menhir_state -> _menhir_box_mustache =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s ->
      let _startpos = _menhir_lexbuf.Lexing.lex_start_p in
      let _endpos = _menhir_lexbuf.Lexing.lex_curr_p in
      let _menhir_stack = MenhirCell1_OPEN_PARTIAL_WITH_PARAMS (_menhir_stack, _menhir_s, _v, _startpos) in
      let _tok = _menhir_lexer _menhir_lexbuf in
      match (_tok : MenhirBasics.token) with
      | UNESCAPE _v_0 ->
          _menhir_run_01 _menhir_stack _menhir_lexbuf _menhir_lexer _v_0 MenhirState05
      | RAW _v_1 ->
          _menhir_run_02 _menhir_stack _menhir_lexbuf _menhir_lexer _v_1 MenhirState05
      | PARTIAL _v_2 ->
          _menhir_run_03 _menhir_stack _menhir_lexbuf _menhir_lexer _v_2 MenhirState05
      | OPEN_SECTION _v_3 ->
          _menhir_run_04 _menhir_stack _menhir_lexbuf _menhir_lexer _v_3 MenhirState05
      | OPEN_PARTIAL_WITH_PARAMS _v_4 ->
          _menhir_run_05 _menhir_stack _menhir_lexbuf _menhir_lexer _v_4 MenhirState05
      | OPEN_PARAM _v_5 ->
          _menhir_run_06 _menhir_stack _menhir_lexbuf _menhir_lexer _v_5 MenhirState05
      | OPEN_INVERTED_SECTION _v_6 ->
          _menhir_run_07 _menhir_stack _menhir_lexbuf _menhir_lexer _v_6 MenhirState05
      | ESCAPE _v_7 ->
          _menhir_run_08 _menhir_stack _menhir_lexbuf _menhir_lexer _v_7 MenhirState05
      | COMMENT _v_8 ->
          _menhir_run_09 _menhir_stack _menhir_lexbuf _menhir_lexer _v_8 MenhirState05
      | CLOSE _ ->
          let _v_9 = _menhir_action_01 () in
          _menhir_run_14 _menhir_stack _menhir_lexbuf _menhir_lexer _endpos _endpos _v_9 MenhirState05 _tok
      | _ ->
          _eRR ()
  
  and _menhir_run_06 : type  ttv_stack. ttv_stack -> _ -> _ -> _ -> (ttv_stack, _menhir_box_mustache) _menhir_state -> _menhir_box_mustache =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s ->
      let _startpos = _menhir_lexbuf.Lexing.lex_start_p in
      let _endpos = _menhir_lexbuf.Lexing.lex_curr_p in
      let _menhir_stack = MenhirCell1_OPEN_PARAM (_menhir_stack, _menhir_s, _v, _startpos) in
      let _tok = _menhir_lexer _menhir_lexbuf in
      match (_tok : MenhirBasics.token) with
      | UNESCAPE _v_0 ->
          _menhir_run_01 _menhir_stack _menhir_lexbuf _menhir_lexer _v_0 MenhirState06
      | RAW _v_1 ->
          _menhir_run_02 _menhir_stack _menhir_lexbuf _menhir_lexer _v_1 MenhirState06
      | PARTIAL _v_2 ->
          _menhir_run_03 _menhir_stack _menhir_lexbuf _menhir_lexer _v_2 MenhirState06
      | OPEN_SECTION _v_3 ->
          _menhir_run_04 _menhir_stack _menhir_lexbuf _menhir_lexer _v_3 MenhirState06
      | OPEN_PARTIAL_WITH_PARAMS _v_4 ->
          _menhir_run_05 _menhir_stack _menhir_lexbuf _menhir_lexer _v_4 MenhirState06
      | OPEN_PARAM _v_5 ->
          _menhir_run_06 _menhir_stack _menhir_lexbuf _menhir_lexer _v_5 MenhirState06
      | OPEN_INVERTED_SECTION _v_6 ->
          _menhir_run_07 _menhir_stack _menhir_lexbuf _menhir_lexer _v_6 MenhirState06
      | ESCAPE _v_7 ->
          _menhir_run_08 _menhir_stack _menhir_lexbuf _menhir_lexer _v_7 MenhirState06
      | COMMENT _v_8 ->
          _menhir_run_09 _menhir_stack _menhir_lexbuf _menhir_lexer _v_8 MenhirState06
      | CLOSE _ ->
          let _v_9 = _menhir_action_01 () in
          _menhir_run_14 _menhir_stack _menhir_lexbuf _menhir_lexer _endpos _endpos _v_9 MenhirState06 _tok
      | _ ->
          _eRR ()
  
  and _menhir_run_07 : type  ttv_stack. ttv_stack -> _ -> _ -> _ -> (ttv_stack, _menhir_box_mustache) _menhir_state -> _menhir_box_mustache =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s ->
      let _startpos = _menhir_lexbuf.Lexing.lex_start_p in
      let _endpos = _menhir_lexbuf.Lexing.lex_curr_p in
      let _menhir_stack = MenhirCell1_OPEN_INVERTED_SECTION (_menhir_stack, _menhir_s, _v, _startpos) in
      let _tok = _menhir_lexer _menhir_lexbuf in
      match (_tok : MenhirBasics.token) with
      | UNESCAPE _v_0 ->
          _menhir_run_01 _menhir_stack _menhir_lexbuf _menhir_lexer _v_0 MenhirState07
      | RAW _v_1 ->
          _menhir_run_02 _menhir_stack _menhir_lexbuf _menhir_lexer _v_1 MenhirState07
      | PARTIAL _v_2 ->
          _menhir_run_03 _menhir_stack _menhir_lexbuf _menhir_lexer _v_2 MenhirState07
      | OPEN_SECTION _v_3 ->
          _menhir_run_04 _menhir_stack _menhir_lexbuf _menhir_lexer _v_3 MenhirState07
      | OPEN_PARTIAL_WITH_PARAMS _v_4 ->
          _menhir_run_05 _menhir_stack _menhir_lexbuf _menhir_lexer _v_4 MenhirState07
      | OPEN_PARAM _v_5 ->
          _menhir_run_06 _menhir_stack _menhir_lexbuf _menhir_lexer _v_5 MenhirState07
      | OPEN_INVERTED_SECTION _v_6 ->
          _menhir_run_07 _menhir_stack _menhir_lexbuf _menhir_lexer _v_6 MenhirState07
      | ESCAPE _v_7 ->
          _menhir_run_08 _menhir_stack _menhir_lexbuf _menhir_lexer _v_7 MenhirState07
      | COMMENT _v_8 ->
          _menhir_run_09 _menhir_stack _menhir_lexbuf _menhir_lexer _v_8 MenhirState07
      | CLOSE _ ->
          let _v_9 = _menhir_action_01 () in
          _menhir_run_14 _menhir_stack _menhir_lexbuf _menhir_lexer _endpos _endpos _v_9 MenhirState07 _tok
      | _ ->
          _eRR ()
  
  and _menhir_run_08 : type  ttv_stack. ttv_stack -> _ -> _ -> _ -> (ttv_stack, _menhir_box_mustache) _menhir_state -> _menhir_box_mustache =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s ->
      let _startpos = _menhir_lexbuf.Lexing.lex_start_p in
      let _endpos = _menhir_lexbuf.Lexing.lex_curr_p in
      let _tok = _menhir_lexer _menhir_lexbuf in
      let (_endpos_elt_, _startpos_elt_, elt) = (_endpos, _startpos, _v) in
      let _v = _menhir_action_04 _endpos_elt_ _startpos_elt_ elt in
      _menhir_goto_mustache_element _menhir_stack _menhir_lexbuf _menhir_lexer _endpos _startpos_elt_ _v _menhir_s _tok
  
  and _menhir_run_09 : type  ttv_stack. ttv_stack -> _ -> _ -> _ -> (ttv_stack, _menhir_box_mustache) _menhir_state -> _menhir_box_mustache =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s ->
      let _startpos = _menhir_lexbuf.Lexing.lex_start_p in
      let _endpos = _menhir_lexbuf.Lexing.lex_curr_p in
      let _tok = _menhir_lexer _menhir_lexbuf in
      let (_endpos_s_, _startpos_s_, s) = (_endpos, _startpos, _v) in
      let _v = _menhir_action_11 _endpos_s_ _startpos_s_ s in
      _menhir_goto_mustache_element _menhir_stack _menhir_lexbuf _menhir_lexer _endpos _startpos_s_ _v _menhir_s _tok
  
  and _menhir_run_14 : type  ttv_stack. ttv_stack -> _ -> _ -> _ -> _ -> _ -> (ttv_stack, _menhir_box_mustache) _menhir_state -> _ -> _menhir_box_mustache =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _endpos _startpos _v _menhir_s _tok ->
      let (_endpos_elts_, _startpos_elts_, elts) = (_endpos, _startpos, _v) in
      let _v = _menhir_action_13 _endpos_elts_ _startpos_elts_ elts in
      _menhir_goto_mustache_expr _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok
  
  and _menhir_goto_mustache_expr : type  ttv_stack. ttv_stack -> _ -> _ -> _ -> (ttv_stack, _menhir_box_mustache) _menhir_state -> _ -> _menhir_box_mustache =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok ->
      match _menhir_s with
      | MenhirState00 ->
          _menhir_run_21 _menhir_stack _v _tok
      | MenhirState04 ->
          _menhir_run_19 _menhir_stack _menhir_lexbuf _menhir_lexer _v _tok
      | MenhirState05 ->
          _menhir_run_17 _menhir_stack _menhir_lexbuf _menhir_lexer _v _tok
      | MenhirState06 ->
          _menhir_run_15 _menhir_stack _menhir_lexbuf _menhir_lexer _v _tok
      | MenhirState07 ->
          _menhir_run_10 _menhir_stack _menhir_lexbuf _menhir_lexer _v _tok
      | _ ->
          _menhir_fail ()
  
  and _menhir_run_19 : type  ttv_stack. (ttv_stack, _menhir_box_mustache) _menhir_cell1_OPEN_SECTION -> _ -> _ -> _ -> _ -> _menhir_box_mustache =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _tok ->
      match (_tok : MenhirBasics.token) with
      | CLOSE _v_0 ->
          let _endpos = _menhir_lexbuf.Lexing.lex_curr_p in
          let _tok = _menhir_lexer _menhir_lexbuf in
          let MenhirCell1_OPEN_SECTION (_menhir_stack, _menhir_s, start_name, _startpos_start_name_) = _menhir_stack in
          let (_endpos_end_name_, end_name, contents) = (_endpos, _v_0, _v) in
          let _v = _menhir_action_06 _endpos_end_name_ _startpos_start_name_ contents end_name start_name in
          _menhir_goto_mustache_element _menhir_stack _menhir_lexbuf _menhir_lexer _endpos _startpos_start_name_ _v _menhir_s _tok
      | _ ->
          _eRR ()
  
  and _menhir_run_17 : type  ttv_stack. (ttv_stack, _menhir_box_mustache) _menhir_cell1_OPEN_PARTIAL_WITH_PARAMS -> _ -> _ -> _ -> _ -> _menhir_box_mustache =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _tok ->
      match (_tok : MenhirBasics.token) with
      | CLOSE _v_0 ->
          let _endpos = _menhir_lexbuf.Lexing.lex_curr_p in
          let _tok = _menhir_lexer _menhir_lexbuf in
          let MenhirCell1_OPEN_PARTIAL_WITH_PARAMS (_menhir_stack, _menhir_s, partial, _startpos_partial_) = _menhir_stack in
          let (_endpos_end_name_, end_name, partial_block) = (_endpos, _v_0, _v) in
          let _v = _menhir_action_09 _endpos_end_name_ _startpos_partial_ end_name partial partial_block in
          _menhir_goto_mustache_element _menhir_stack _menhir_lexbuf _menhir_lexer _endpos _startpos_partial_ _v _menhir_s _tok
      | _ ->
          _eRR ()
  
  and _menhir_run_15 : type  ttv_stack. (ttv_stack, _menhir_box_mustache) _menhir_cell1_OPEN_PARAM -> _ -> _ -> _ -> _ -> _menhir_box_mustache =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _tok ->
      match (_tok : MenhirBasics.token) with
      | CLOSE _v_0 ->
          let _endpos = _menhir_lexbuf.Lexing.lex_curr_p in
          let _tok = _menhir_lexer _menhir_lexbuf in
          let MenhirCell1_OPEN_PARAM (_menhir_stack, _menhir_s, param, _startpos_param_) = _menhir_stack in
          let (_endpos_end_name_, end_name, contents) = (_endpos, _v_0, _v) in
          let _v = _menhir_action_10 _endpos_end_name_ _startpos_param_ contents end_name param in
          _menhir_goto_mustache_element _menhir_stack _menhir_lexbuf _menhir_lexer _endpos _startpos_param_ _v _menhir_s _tok
      | _ ->
          _eRR ()
  
  and _menhir_run_10 : type  ttv_stack. (ttv_stack, _menhir_box_mustache) _menhir_cell1_OPEN_INVERTED_SECTION -> _ -> _ -> _ -> _ -> _menhir_box_mustache =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _tok ->
      match (_tok : MenhirBasics.token) with
      | CLOSE _v_0 ->
          let _endpos = _menhir_lexbuf.Lexing.lex_curr_p in
          let _tok = _menhir_lexer _menhir_lexbuf in
          let MenhirCell1_OPEN_INVERTED_SECTION (_menhir_stack, _menhir_s, start_name, _startpos_start_name_) = _menhir_stack in
          let (_endpos_end_name_, end_name, contents) = (_endpos, _v_0, _v) in
          let _v = _menhir_action_07 _endpos_end_name_ _startpos_start_name_ contents end_name start_name in
          _menhir_goto_mustache_element _menhir_stack _menhir_lexbuf _menhir_lexer _endpos _startpos_start_name_ _v _menhir_s _tok
      | _ ->
          _eRR ()
  
  and _menhir_run_13 : type  ttv_stack. (ttv_stack, _menhir_box_mustache) _menhir_cell1_mustache_element -> _ -> _ -> _ -> _ -> _ -> _menhir_box_mustache =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _endpos _v _tok ->
      let MenhirCell1_mustache_element (_menhir_stack, _menhir_s, x, _startpos_x_) = _menhir_stack in
      let (_endpos_xs_, xs) = (_endpos, _v) in
      let _v = _menhir_action_02 x xs in
      _menhir_goto_list_mustache_element_ _menhir_stack _menhir_lexbuf _menhir_lexer _endpos_xs_ _startpos_x_ _v _menhir_s _tok
  
  and _menhir_goto_list_mustache_element_ : type  ttv_stack. ttv_stack -> _ -> _ -> _ -> _ -> _ -> (ttv_stack, _menhir_box_mustache) _menhir_state -> _ -> _menhir_box_mustache =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _endpos _startpos _v _menhir_s _tok ->
      match _menhir_s with
      | MenhirState00 ->
          _menhir_run_14 _menhir_stack _menhir_lexbuf _menhir_lexer _endpos _startpos _v _menhir_s _tok
      | MenhirState04 ->
          _menhir_run_14 _menhir_stack _menhir_lexbuf _menhir_lexer _endpos _startpos _v _menhir_s _tok
      | MenhirState05 ->
          _menhir_run_14 _menhir_stack _menhir_lexbuf _menhir_lexer _endpos _startpos _v _menhir_s _tok
      | MenhirState06 ->
          _menhir_run_14 _menhir_stack _menhir_lexbuf _menhir_lexer _endpos _startpos _v _menhir_s _tok
      | MenhirState07 ->
          _menhir_run_14 _menhir_stack _menhir_lexbuf _menhir_lexer _endpos _startpos _v _menhir_s _tok
      | MenhirState12 ->
          _menhir_run_13 _menhir_stack _menhir_lexbuf _menhir_lexer _endpos _v _tok
  
  let _menhir_run_00 : type  ttv_stack. ttv_stack -> _ -> _ -> _menhir_box_mustache =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer ->
      let _endpos = _menhir_lexbuf.Lexing.lex_curr_p in
      let _tok = _menhir_lexer _menhir_lexbuf in
      match (_tok : MenhirBasics.token) with
      | UNESCAPE _v ->
          _menhir_run_01 _menhir_stack _menhir_lexbuf _menhir_lexer _v MenhirState00
      | RAW _v ->
          _menhir_run_02 _menhir_stack _menhir_lexbuf _menhir_lexer _v MenhirState00
      | PARTIAL _v ->
          _menhir_run_03 _menhir_stack _menhir_lexbuf _menhir_lexer _v MenhirState00
      | OPEN_SECTION _v ->
          _menhir_run_04 _menhir_stack _menhir_lexbuf _menhir_lexer _v MenhirState00
      | OPEN_PARTIAL_WITH_PARAMS _v ->
          _menhir_run_05 _menhir_stack _menhir_lexbuf _menhir_lexer _v MenhirState00
      | OPEN_PARAM _v ->
          _menhir_run_06 _menhir_stack _menhir_lexbuf _menhir_lexer _v MenhirState00
      | OPEN_INVERTED_SECTION _v ->
          _menhir_run_07 _menhir_stack _menhir_lexbuf _menhir_lexer _v MenhirState00
      | ESCAPE _v ->
          _menhir_run_08 _menhir_stack _menhir_lexbuf _menhir_lexer _v MenhirState00
      | COMMENT _v ->
          _menhir_run_09 _menhir_stack _menhir_lexbuf _menhir_lexer _v MenhirState00
      | EOF ->
          let _v = _menhir_action_01 () in
          _menhir_run_14 _menhir_stack _menhir_lexbuf _menhir_lexer _endpos _endpos _v MenhirState00 _tok
      | _ ->
          _eRR ()
  
end

let mustache =
  fun _menhir_lexer _menhir_lexbuf ->
    let _menhir_stack = () in
    let MenhirBox_mustache v = _menhir_run_00 _menhir_stack _menhir_lexbuf _menhir_lexer in
    v

# 155 "mustache/lib/mustache_parser.mly"
  

# 738 "mustache/lib/mustache_parser.ml"