Source file 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

module MenhirBasics = struct
  
  exception Error
  
  let _eRR =
    fun _s ->
      raise Error
  
  type token = 
    | VAR
    | RULES
    | RPAREN
    | LPAREN
    | ID of (
# 3 "lib/parser.mly"
       (Types.id)
# 19 "lib/parser.ml"
  )
    | EOF
    | COMMENT_SECTION of (
# 11 "lib/parser.mly"
       (string)
# 25 "lib/parser.ml"
  )
    | COMMA
    | ARROW
  
end

include MenhirBasics

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

  | MenhirState02 : (('s, _menhir_box_trs) _menhir_cell1_LPAREN, _menhir_box_trs) _menhir_state
    (** State 02.
        Stack shape : LPAREN.
        Start symbol: trs. *)

  | MenhirState03 : (('s, _menhir_box_trs) _menhir_cell1_ID, _menhir_box_trs) _menhir_state
    (** State 03.
        Stack shape : ID.
        Start symbol: trs. *)

  | MenhirState07 : (('s, _menhir_box_trs) _menhir_cell1_LPAREN, _menhir_box_trs) _menhir_state
    (** State 07.
        Stack shape : LPAREN.
        Start symbol: trs. *)

  | MenhirState09 : (('s, _menhir_box_trs) _menhir_cell1_ID, _menhir_box_trs) _menhir_state
    (** State 09.
        Stack shape : ID.
        Start symbol: trs. *)

  | MenhirState14 : (('s, _menhir_box_trs) _menhir_cell1_term, _menhir_box_trs) _menhir_state
    (** State 14.
        Stack shape : term.
        Start symbol: trs. *)

  | MenhirState17 : (('s, _menhir_box_trs) _menhir_cell1_term, _menhir_box_trs) _menhir_state
    (** State 17.
        Stack shape : term.
        Start symbol: trs. *)

  | MenhirState21 : (('s, _menhir_box_trs) _menhir_cell1_rule, _menhir_box_trs) _menhir_state
    (** State 21.
        Stack shape : rule.
        Start symbol: trs. *)

  | MenhirState23 : (('s, _menhir_box_trs) _menhir_cell1_var, _menhir_box_trs) _menhir_state
    (** State 23.
        Stack shape : var.
        Start symbol: trs. *)

  | MenhirState25 : ((('s, _menhir_box_trs) _menhir_cell1_var, _menhir_box_trs) _menhir_cell1_rules, _menhir_box_trs) _menhir_state
    (** State 25.
        Stack shape : var rules.
        Start symbol: trs. *)

  | MenhirState30 : (('s, _menhir_box_trs) _menhir_cell1_rules, _menhir_box_trs) _menhir_state
    (** State 30.
        Stack shape : rules.
        Start symbol: trs. *)


and ('s, 'r) _menhir_cell1_rule = 
  | MenhirCell1_rule of 's * ('s, 'r) _menhir_state * (Types.rule)

and ('s, 'r) _menhir_cell1_rules = 
  | MenhirCell1_rules of 's * ('s, 'r) _menhir_state * (Types.rule list)

and ('s, 'r) _menhir_cell1_term = 
  | MenhirCell1_term of 's * ('s, 'r) _menhir_state * (Types.term)

and ('s, 'r) _menhir_cell1_var = 
  | MenhirCell1_var of 's * ('s, 'r) _menhir_state * (string list)

and ('s, 'r) _menhir_cell1_ID = 
  | MenhirCell1_ID of 's * ('s, 'r) _menhir_state * (
# 3 "lib/parser.mly"
       (Types.id)
# 107 "lib/parser.ml"
)

and ('s, 'r) _menhir_cell1_LPAREN = 
  | MenhirCell1_LPAREN of 's * ('s, 'r) _menhir_state

and _menhir_box_trs = 
  | MenhirBox_trs of (Types.trs) [@@unboxed]

let _menhir_action_01 =
  fun () ->
    (
# 54 "lib/parser.mly"
                    ( None )
# 121 "lib/parser.ml"
     : (string option))

let _menhir_action_02 =
  fun s ->
    (
# 55 "lib/parser.mly"
                    ( Some s )
# 129 "lib/parser.ml"
     : (string option))

let _menhir_action_03 =
  fun () ->
    (
# 31 "lib/parser.mly"
                       ( [] )
# 137 "lib/parser.ml"
     : (string list))

let _menhir_action_04 =
  fun id idlist ->
    (
# 32 "lib/parser.mly"
                       ( id :: idlist )
# 145 "lib/parser.ml"
     : (string list))

let _menhir_action_05 =
  fun l r ->
    (
# 42 "lib/parser.mly"
                        ( (l, r) )
# 153 "lib/parser.ml"
     : (Types.rule))

let _menhir_action_06 =
  fun () ->
    (
# 38 "lib/parser.mly"
                               ( [] )
# 161 "lib/parser.ml"
     : (Types.rule list))

let _menhir_action_07 =
  fun rule rulelist ->
    (
# 39 "lib/parser.mly"
                               ( rule :: rulelist )
# 169 "lib/parser.ml"
     : (Types.rule list))

let _menhir_action_08 =
  fun rulelist ->
    (
# 35 "lib/parser.mly"
                                           ( rulelist )
# 177 "lib/parser.ml"
     : (Types.rule list))

let _menhir_action_09 =
  fun id ->
    (
# 45 "lib/parser.mly"
                        ( Types.Var id )
# 185 "lib/parser.ml"
     : (Types.term))

let _menhir_action_10 =
  fun id ->
    (
# 46 "lib/parser.mly"
                        ( Types.App (id, []) )
# 193 "lib/parser.ml"
     : (Types.term))

let _menhir_action_11 =
  fun id termlist ->
    (
# 47 "lib/parser.mly"
                                           ( Types.App (id, termlist) )
# 201 "lib/parser.ml"
     : (Types.term))

let _menhir_action_12 =
  fun term ->
    (
# 50 "lib/parser.mly"
            ( [term] )
# 209 "lib/parser.ml"
     : (Types.term list))

let _menhir_action_13 =
  fun term termlist ->
    (
# 51 "lib/parser.mly"
                                      ( term :: termlist )
# 217 "lib/parser.ml"
     : (Types.term list))

let _menhir_action_14 =
  fun comment rules var ->
    (
# 24 "lib/parser.mly"
  ( Types.({ var=Some var; rules; comment }) )
# 225 "lib/parser.ml"
     : (Types.trs))

let _menhir_action_15 =
  fun comment rules ->
    (
# 25 "lib/parser.mly"
                                    ( Types.({ var=None; rules; comment }) )
# 233 "lib/parser.ml"
     : (Types.trs))

let _menhir_action_16 =
  fun idlist ->
    (
# 28 "lib/parser.mly"
                                     ( idlist )
# 241 "lib/parser.ml"
     : (string list))

let _menhir_print_token : token -> string =
  fun _tok ->
    match _tok with
    | ARROW ->
        "ARROW"
    | COMMA ->
        "COMMA"
    | COMMENT_SECTION _ ->
        "COMMENT_SECTION"
    | EOF ->
        "EOF"
    | ID _ ->
        "ID"
    | LPAREN ->
        "LPAREN"
    | RPAREN ->
        "RPAREN"
    | RULES ->
        "RULES"
    | VAR ->
        "VAR"

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_goto_trs : type  ttv_stack. ttv_stack -> _ -> _menhir_box_trs =
    fun _menhir_stack _v ->
      MenhirBox_trs _v
  
  let _menhir_run_31 : type  ttv_stack. (ttv_stack, _menhir_box_trs) _menhir_cell1_rules -> _ -> _ -> _menhir_box_trs =
    fun _menhir_stack _v _tok ->
      match (_tok : MenhirBasics.token) with
      | EOF ->
          let MenhirCell1_rules (_menhir_stack, _, rules) = _menhir_stack in
          let comment = _v in
          let _v = _menhir_action_15 comment rules in
          _menhir_goto_trs _menhir_stack _v
      | _ ->
          _eRR ()
  
  let _menhir_run_27 : type  ttv_stack. ((ttv_stack, _menhir_box_trs) _menhir_cell1_var, _menhir_box_trs) _menhir_cell1_rules -> _ -> _ -> _menhir_box_trs =
    fun _menhir_stack _v _tok ->
      match (_tok : MenhirBasics.token) with
      | EOF ->
          let MenhirCell1_rules (_menhir_stack, _, rules) = _menhir_stack in
          let MenhirCell1_var (_menhir_stack, _, var) = _menhir_stack in
          let comment = _v in
          let _v = _menhir_action_14 comment rules var in
          _menhir_goto_trs _menhir_stack _v
      | _ ->
          _eRR ()
  
  let _menhir_goto_comment : type  ttv_stack. ((ttv_stack, _menhir_box_trs) _menhir_cell1_rules as 'stack) -> _ -> ('stack, _menhir_box_trs) _menhir_state -> _ -> _menhir_box_trs =
    fun _menhir_stack _v _menhir_s _tok ->
      match _menhir_s with
      | MenhirState30 ->
          _menhir_run_31 _menhir_stack _v _tok
      | MenhirState25 ->
          _menhir_run_27 _menhir_stack _v _tok
      | _ ->
          _menhir_fail ()
  
  let _menhir_run_26 : type  ttv_stack. ((ttv_stack, _menhir_box_trs) _menhir_cell1_rules as 'stack) -> _ -> _ -> _ -> ('stack, _menhir_box_trs) _menhir_state -> _menhir_box_trs =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s ->
      let _tok = _menhir_lexer _menhir_lexbuf in
      let s = _v in
      let _v = _menhir_action_02 s in
      _menhir_goto_comment _menhir_stack _v _menhir_s _tok
  
  let _menhir_run_30 : type  ttv_stack. ttv_stack -> _ -> _ -> _ -> (ttv_stack, _menhir_box_trs) _menhir_state -> _ -> _menhir_box_trs =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok ->
      let _menhir_stack = MenhirCell1_rules (_menhir_stack, _menhir_s, _v) in
      match (_tok : MenhirBasics.token) with
      | COMMENT_SECTION _v_0 ->
          _menhir_run_26 _menhir_stack _menhir_lexbuf _menhir_lexer _v_0 MenhirState30
      | EOF ->
          let _v_1 = _menhir_action_01 () in
          _menhir_run_31 _menhir_stack _v_1 _tok
      | _ ->
          _eRR ()
  
  let _menhir_run_25 : type  ttv_stack. ((ttv_stack, _menhir_box_trs) _menhir_cell1_var as 'stack) -> _ -> _ -> _ -> ('stack, _menhir_box_trs) _menhir_state -> _ -> _menhir_box_trs =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok ->
      let _menhir_stack = MenhirCell1_rules (_menhir_stack, _menhir_s, _v) in
      match (_tok : MenhirBasics.token) with
      | COMMENT_SECTION _v_0 ->
          _menhir_run_26 _menhir_stack _menhir_lexbuf _menhir_lexer _v_0 MenhirState25
      | EOF ->
          let _v_1 = _menhir_action_01 () in
          _menhir_run_27 _menhir_stack _v_1 _tok
      | _ ->
          _eRR ()
  
  let _menhir_goto_rules : type  ttv_stack. ttv_stack -> _ -> _ -> _ -> (ttv_stack, _menhir_box_trs) _menhir_state -> _ -> _menhir_box_trs =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok ->
      match _menhir_s with
      | MenhirState00 ->
          _menhir_run_30 _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok
      | MenhirState23 ->
          _menhir_run_25 _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok
      | _ ->
          _menhir_fail ()
  
  let _menhir_run_19 : type  ttv_stack. (ttv_stack, _menhir_box_trs) _menhir_cell1_LPAREN -> _ -> _ -> _ -> _menhir_box_trs =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _v ->
      let _tok = _menhir_lexer _menhir_lexbuf in
      let MenhirCell1_LPAREN (_menhir_stack, _menhir_s) = _menhir_stack in
      let rulelist = _v in
      let _v = _menhir_action_08 rulelist in
      _menhir_goto_rules _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok
  
  let rec _menhir_run_22 : type  ttv_stack. (ttv_stack, _menhir_box_trs) _menhir_cell1_rule -> _ -> _ -> _ -> _menhir_box_trs =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _v ->
      let MenhirCell1_rule (_menhir_stack, _menhir_s, rule) = _menhir_stack in
      let rulelist = _v in
      let _v = _menhir_action_07 rule rulelist in
      _menhir_goto_rulelist _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s
  
  and _menhir_goto_rulelist : type  ttv_stack. ttv_stack -> _ -> _ -> _ -> (ttv_stack, _menhir_box_trs) _menhir_state -> _menhir_box_trs =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s ->
      match _menhir_s with
      | MenhirState21 ->
          _menhir_run_22 _menhir_stack _menhir_lexbuf _menhir_lexer _v
      | MenhirState07 ->
          _menhir_run_19 _menhir_stack _menhir_lexbuf _menhir_lexer _v
      | _ ->
          _menhir_fail ()
  
  let rec _menhir_run_08 : type  ttv_stack. ttv_stack -> _ -> _ -> _ -> (ttv_stack, _menhir_box_trs) _menhir_state -> _menhir_box_trs =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s ->
      let _tok = _menhir_lexer _menhir_lexbuf in
      match (_tok : MenhirBasics.token) with
      | LPAREN ->
          let _tok = _menhir_lexer _menhir_lexbuf in
          (match (_tok : MenhirBasics.token) with
          | RPAREN ->
              let _tok = _menhir_lexer _menhir_lexbuf in
              let id = _v in
              let _v = _menhir_action_10 id in
              _menhir_goto_term _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok
          | ID _v_0 ->
              let _menhir_stack = MenhirCell1_ID (_menhir_stack, _menhir_s, _v) in
              _menhir_run_08 _menhir_stack _menhir_lexbuf _menhir_lexer _v_0 MenhirState09
          | _ ->
              _eRR ())
      | ARROW | COMMA | ID _ | RPAREN ->
          let id = _v in
          let _v = _menhir_action_09 id in
          _menhir_goto_term _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok
      | _ ->
          _eRR ()
  
  and _menhir_goto_term : type  ttv_stack. ttv_stack -> _ -> _ -> _ -> (ttv_stack, _menhir_box_trs) _menhir_state -> _ -> _menhir_box_trs =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok ->
      match _menhir_s with
      | MenhirState17 ->
          _menhir_run_18 _menhir_stack _menhir_lexbuf _menhir_lexer _v _tok
      | MenhirState21 ->
          _menhir_run_16 _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok
      | MenhirState07 ->
          _menhir_run_16 _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok
      | MenhirState14 ->
          _menhir_run_13 _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok
      | MenhirState09 ->
          _menhir_run_13 _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok
      | _ ->
          _menhir_fail ()
  
  and _menhir_run_18 : type  ttv_stack. (ttv_stack, _menhir_box_trs) _menhir_cell1_term -> _ -> _ -> _ -> _ -> _menhir_box_trs =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _tok ->
      let MenhirCell1_term (_menhir_stack, _menhir_s, l) = _menhir_stack in
      let r = _v in
      let _v = _menhir_action_05 l r in
      let _menhir_stack = MenhirCell1_rule (_menhir_stack, _menhir_s, _v) in
      match (_tok : MenhirBasics.token) with
      | ID _v_0 ->
          _menhir_run_08 _menhir_stack _menhir_lexbuf _menhir_lexer _v_0 MenhirState21
      | RPAREN ->
          let _v_1 = _menhir_action_06 () in
          _menhir_run_22 _menhir_stack _menhir_lexbuf _menhir_lexer _v_1
      | _ ->
          _eRR ()
  
  and _menhir_run_16 : type  ttv_stack. ttv_stack -> _ -> _ -> _ -> (ttv_stack, _menhir_box_trs) _menhir_state -> _ -> _menhir_box_trs =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok ->
      let _menhir_stack = MenhirCell1_term (_menhir_stack, _menhir_s, _v) in
      match (_tok : MenhirBasics.token) with
      | ARROW ->
          let _menhir_s = MenhirState17 in
          let _tok = _menhir_lexer _menhir_lexbuf in
          (match (_tok : MenhirBasics.token) with
          | ID _v ->
              _menhir_run_08 _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s
          | _ ->
              _eRR ())
      | _ ->
          _eRR ()
  
  and _menhir_run_13 : type  ttv_stack. ttv_stack -> _ -> _ -> _ -> (ttv_stack, _menhir_box_trs) _menhir_state -> _ -> _menhir_box_trs =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok ->
      match (_tok : MenhirBasics.token) with
      | COMMA ->
          let _menhir_stack = MenhirCell1_term (_menhir_stack, _menhir_s, _v) in
          let _menhir_s = MenhirState14 in
          let _tok = _menhir_lexer _menhir_lexbuf in
          (match (_tok : MenhirBasics.token) with
          | ID _v ->
              _menhir_run_08 _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s
          | _ ->
              _eRR ())
      | RPAREN ->
          let term = _v in
          let _v = _menhir_action_12 term in
          _menhir_goto_termlist _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s
      | _ ->
          _eRR ()
  
  and _menhir_goto_termlist : type  ttv_stack. ttv_stack -> _ -> _ -> _ -> (ttv_stack, _menhir_box_trs) _menhir_state -> _menhir_box_trs =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s ->
      match _menhir_s with
      | MenhirState14 ->
          _menhir_run_15 _menhir_stack _menhir_lexbuf _menhir_lexer _v
      | MenhirState09 ->
          _menhir_run_11 _menhir_stack _menhir_lexbuf _menhir_lexer _v
      | _ ->
          _menhir_fail ()
  
  and _menhir_run_15 : type  ttv_stack. (ttv_stack, _menhir_box_trs) _menhir_cell1_term -> _ -> _ -> _ -> _menhir_box_trs =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _v ->
      let MenhirCell1_term (_menhir_stack, _menhir_s, term) = _menhir_stack in
      let termlist = _v in
      let _v = _menhir_action_13 term termlist in
      _menhir_goto_termlist _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s
  
  and _menhir_run_11 : type  ttv_stack. (ttv_stack, _menhir_box_trs) _menhir_cell1_ID -> _ -> _ -> _ -> _menhir_box_trs =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _v ->
      let _tok = _menhir_lexer _menhir_lexbuf in
      let MenhirCell1_ID (_menhir_stack, _menhir_s, id) = _menhir_stack in
      let termlist = _v in
      let _v = _menhir_action_11 id termlist in
      _menhir_goto_term _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok
  
  let _menhir_run_07 : type  ttv_stack. (ttv_stack, _menhir_box_trs) _menhir_cell1_LPAREN -> _ -> _ -> _menhir_box_trs =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer ->
      let _tok = _menhir_lexer _menhir_lexbuf in
      match (_tok : MenhirBasics.token) with
      | ID _v ->
          _menhir_run_08 _menhir_stack _menhir_lexbuf _menhir_lexer _v MenhirState07
      | RPAREN ->
          let _v = _menhir_action_06 () in
          _menhir_run_19 _menhir_stack _menhir_lexbuf _menhir_lexer _v
      | _ ->
          _eRR ()
  
  let _menhir_run_05 : type  ttv_stack. (ttv_stack, _menhir_box_trs) _menhir_cell1_LPAREN -> _ -> _ -> _ -> _menhir_box_trs =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _v ->
      let _tok = _menhir_lexer _menhir_lexbuf in
      let MenhirCell1_LPAREN (_menhir_stack, _menhir_s) = _menhir_stack in
      let idlist = _v in
      let _v = _menhir_action_16 idlist in
      let _menhir_stack = MenhirCell1_var (_menhir_stack, _menhir_s, _v) in
      match (_tok : MenhirBasics.token) with
      | LPAREN ->
          let _menhir_stack = MenhirCell1_LPAREN (_menhir_stack, MenhirState23) in
          let _tok = _menhir_lexer _menhir_lexbuf in
          (match (_tok : MenhirBasics.token) with
          | RULES ->
              _menhir_run_07 _menhir_stack _menhir_lexbuf _menhir_lexer
          | _ ->
              _eRR ())
      | _ ->
          _eRR ()
  
  let rec _menhir_run_04 : type  ttv_stack. (ttv_stack, _menhir_box_trs) _menhir_cell1_ID -> _ -> _ -> _ -> _menhir_box_trs =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _v ->
      let MenhirCell1_ID (_menhir_stack, _menhir_s, id) = _menhir_stack in
      let idlist = _v in
      let _v = _menhir_action_04 id idlist in
      _menhir_goto_idlist _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s
  
  and _menhir_goto_idlist : type  ttv_stack. ttv_stack -> _ -> _ -> _ -> (ttv_stack, _menhir_box_trs) _menhir_state -> _menhir_box_trs =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s ->
      match _menhir_s with
      | MenhirState02 ->
          _menhir_run_05 _menhir_stack _menhir_lexbuf _menhir_lexer _v
      | MenhirState03 ->
          _menhir_run_04 _menhir_stack _menhir_lexbuf _menhir_lexer _v
      | _ ->
          _menhir_fail ()
  
  let rec _menhir_run_03 : type  ttv_stack. ttv_stack -> _ -> _ -> _ -> (ttv_stack, _menhir_box_trs) _menhir_state -> _menhir_box_trs =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s ->
      let _menhir_stack = MenhirCell1_ID (_menhir_stack, _menhir_s, _v) in
      let _tok = _menhir_lexer _menhir_lexbuf in
      match (_tok : MenhirBasics.token) with
      | ID _v_0 ->
          _menhir_run_03 _menhir_stack _menhir_lexbuf _menhir_lexer _v_0 MenhirState03
      | RPAREN ->
          let _v_1 = _menhir_action_03 () in
          _menhir_run_04 _menhir_stack _menhir_lexbuf _menhir_lexer _v_1
      | _ ->
          _eRR ()
  
  let _menhir_run_00 : type  ttv_stack. ttv_stack -> _ -> _ -> _menhir_box_trs =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer ->
      let _tok = _menhir_lexer _menhir_lexbuf in
      match (_tok : MenhirBasics.token) with
      | LPAREN ->
          let _menhir_stack = MenhirCell1_LPAREN (_menhir_stack, MenhirState00) in
          let _tok = _menhir_lexer _menhir_lexbuf in
          (match (_tok : MenhirBasics.token) with
          | VAR ->
              let _tok = _menhir_lexer _menhir_lexbuf in
              (match (_tok : MenhirBasics.token) with
              | ID _v ->
                  _menhir_run_03 _menhir_stack _menhir_lexbuf _menhir_lexer _v MenhirState02
              | RPAREN ->
                  let _v = _menhir_action_03 () in
                  _menhir_run_05 _menhir_stack _menhir_lexbuf _menhir_lexer _v
              | _ ->
                  _eRR ())
          | RULES ->
              _menhir_run_07 _menhir_stack _menhir_lexbuf _menhir_lexer
          | _ ->
              _eRR ())
      | _ ->
          _eRR ()
  
end

let trs =
  fun _menhir_lexer _menhir_lexbuf ->
    let _menhir_stack = () in
    let MenhirBox_trs v = _menhir_run_00 _menhir_stack _menhir_lexbuf _menhir_lexer in
    v