package stog_writing

  1. Overview
  2. Docs

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

module MenhirBasics = struct
  
  exception Error
  
  let _eRR =
    fun _s ->
      raise Error
  
  type token = 
    | String of (
# 40 "plugins/bibtex_parser.mly"
       (string)
# 15 "plugins/bibtex_parser.ml"
  )
    | RBRACE
    | LBRACE
    | Ident of (
# 39 "plugins/bibtex_parser.mly"
       (string)
# 22 "plugins/bibtex_parser.ml"
  )
    | Equal_braced_string of (
# 41 "plugins/bibtex_parser.mly"
       (string)
# 27 "plugins/bibtex_parser.ml"
  )
    | Entry_kind of (
# 37 "plugins/bibtex_parser.mly"
       (string)
# 32 "plugins/bibtex_parser.ml"
  )
    | EQUAL
    | EOF
    | COMMA
  
end

include MenhirBasics

# 31 "plugins/bibtex_parser.mly"
  
open Bibtex


# 47 "plugins/bibtex_parser.ml"

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

  | MenhirState04 : (('s, _menhir_box_entries) _menhir_cell1_Entry_kind _menhir_cell0_Ident, _menhir_box_entries) _menhir_state
    (** State 04.
        Stack shape : Entry_kind Ident.
        Start symbol: entries. *)

  | MenhirState06 : (('s, _menhir_box_entries) _menhir_cell1_Ident _menhir_cell0_Equal_braced_string, _menhir_box_entries) _menhir_state
    (** State 06.
        Stack shape : Ident Equal_braced_string.
        Start symbol: entries. *)

  | MenhirState10 : (('s, _menhir_box_entries) _menhir_cell1_Ident _menhir_cell0_String, _menhir_box_entries) _menhir_state
    (** State 10.
        Stack shape : Ident String.
        Start symbol: entries. *)

  | MenhirState14 : (('s, _menhir_box_entries) _menhir_cell1_field, _menhir_box_entries) _menhir_state
    (** State 14.
        Stack shape : field.
        Start symbol: entries. *)

  | MenhirState19 : (('s, _menhir_box_entries) _menhir_cell1_entry, _menhir_box_entries) _menhir_state
    (** State 19.
        Stack shape : entry.
        Start symbol: entries. *)


and ('s, 'r) _menhir_cell1_entry = 
  | MenhirCell1_entry of 's * ('s, 'r) _menhir_state * (Bibtex.entry)

and ('s, 'r) _menhir_cell1_field = 
  | MenhirCell1_field of 's * ('s, 'r) _menhir_state * (string * string)

and ('s, 'r) _menhir_cell1_list_entry_ = 
  | MenhirCell1_list_entry_ of 's * ('s, 'r) _menhir_state * (Bibtex.entry list)

and ('s, 'r) _menhir_cell1_Entry_kind = 
  | MenhirCell1_Entry_kind of 's * ('s, 'r) _menhir_state * (
# 37 "plugins/bibtex_parser.mly"
       (string)
# 94 "plugins/bibtex_parser.ml"
)

and 's _menhir_cell0_Equal_braced_string = 
  | MenhirCell0_Equal_braced_string of 's * (
# 41 "plugins/bibtex_parser.mly"
       (string)
# 101 "plugins/bibtex_parser.ml"
)

and ('s, 'r) _menhir_cell1_Ident = 
  | MenhirCell1_Ident of 's * ('s, 'r) _menhir_state * (
# 39 "plugins/bibtex_parser.mly"
       (string)
# 108 "plugins/bibtex_parser.ml"
)

and 's _menhir_cell0_Ident = 
  | MenhirCell0_Ident of 's * (
# 39 "plugins/bibtex_parser.mly"
       (string)
# 115 "plugins/bibtex_parser.ml"
)

and 's _menhir_cell0_String = 
  | MenhirCell0_String of 's * (
# 40 "plugins/bibtex_parser.mly"
       (string)
# 122 "plugins/bibtex_parser.ml"
)

and _menhir_box_entries = 
  | MenhirBox_entries of (Bibtex.entry list) [@@unboxed]

let _menhir_action_01 =
  fun _1 ->
    (
# 46 "plugins/bibtex_parser.mly"
                                         ( _1 )
# 133 "plugins/bibtex_parser.ml"
     : (Bibtex.entry list))

let _menhir_action_02 =
  fun id k l ->
    (
# 50 "plugins/bibtex_parser.mly"
  (
    { kind = String.lowercase_ascii k ; id = id ; fields = l }
  )
# 143 "plugins/bibtex_parser.ml"
     : (Bibtex.entry))

let _menhir_action_03 =
  fun n s ->
    (
# 54 "plugins/bibtex_parser.mly"
                                       ( (String.lowercase_ascii n, s) )
# 151 "plugins/bibtex_parser.ml"
     : (string * string))

let _menhir_action_04 =
  fun n s ->
    (
# 55 "plugins/bibtex_parser.mly"
                                              ( (String.lowercase_ascii n, s) )
# 159 "plugins/bibtex_parser.ml"
     : (string * string))

let _menhir_action_05 =
  fun () ->
    (
# 216 "<standard.mly>"
    ( [] )
# 167 "plugins/bibtex_parser.ml"
     : (Bibtex.entry list))

let _menhir_action_06 =
  fun x xs ->
    (
# 219 "<standard.mly>"
    ( x :: xs )
# 175 "plugins/bibtex_parser.ml"
     : (Bibtex.entry list))

let _menhir_action_07 =
  fun () ->
    (
# 216 "<standard.mly>"
    ( [] )
# 183 "plugins/bibtex_parser.ml"
     : ((string * string) list))

let _menhir_action_08 =
  fun x xs ->
    (
# 219 "<standard.mly>"
    ( x :: xs )
# 191 "plugins/bibtex_parser.ml"
     : ((string * string) list))

let _menhir_action_09 =
  fun () ->
    (
# 111 "<standard.mly>"
    ( None )
# 199 "plugins/bibtex_parser.ml"
     : (unit option))

let _menhir_action_10 =
  fun x ->
    (
# 114 "<standard.mly>"
    ( Some x )
# 207 "plugins/bibtex_parser.ml"
     : (unit option))

let _menhir_action_11 =
  fun () ->
    (
# 111 "<standard.mly>"
    ( None )
# 215 "plugins/bibtex_parser.ml"
     : (unit option))

let _menhir_action_12 =
  fun x ->
    (
# 114 "<standard.mly>"
    ( Some x )
# 223 "plugins/bibtex_parser.ml"
     : (unit option))

let _menhir_print_token : token -> string =
  fun _tok ->
    match _tok with
    | COMMA ->
        "COMMA"
    | EOF ->
        "EOF"
    | EQUAL ->
        "EQUAL"
    | Entry_kind _ ->
        "Entry_kind"
    | Equal_braced_string _ ->
        "Equal_braced_string"
    | Ident _ ->
        "Ident"
    | LBRACE ->
        "LBRACE"
    | RBRACE ->
        "RBRACE"
    | String _ ->
        "String"

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_16 : type  ttv_stack. ttv_stack -> _ -> (ttv_stack, _menhir_box_entries) _menhir_state -> _menhir_box_entries =
    fun _menhir_stack _v _menhir_s ->
      let _menhir_stack = MenhirCell1_list_entry_ (_menhir_stack, _menhir_s, _v) in
      let x = () in
      let _ = _menhir_action_12 x in
      let MenhirCell1_list_entry_ (_menhir_stack, _, _1) = _menhir_stack in
      let _v = _menhir_action_01 _1 in
      MenhirBox_entries _v
  
  let rec _menhir_run_20 : type  ttv_stack. (ttv_stack, _menhir_box_entries) _menhir_cell1_entry -> _ -> _menhir_box_entries =
    fun _menhir_stack _v ->
      let MenhirCell1_entry (_menhir_stack, _menhir_s, x) = _menhir_stack in
      let xs = _v in
      let _v = _menhir_action_06 x xs in
      _menhir_goto_list_entry_ _menhir_stack _v _menhir_s
  
  and _menhir_goto_list_entry_ : type  ttv_stack. ttv_stack -> _ -> (ttv_stack, _menhir_box_entries) _menhir_state -> _menhir_box_entries =
    fun _menhir_stack _v _menhir_s ->
      match _menhir_s with
      | MenhirState19 ->
          _menhir_run_20 _menhir_stack _v
      | MenhirState00 ->
          _menhir_run_16 _menhir_stack _v _menhir_s
      | _ ->
          _menhir_fail ()
  
  let rec _menhir_run_01 : type  ttv_stack. ttv_stack -> _ -> _ -> _ -> (ttv_stack, _menhir_box_entries) _menhir_state -> _menhir_box_entries =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s ->
      let _menhir_stack = MenhirCell1_Entry_kind (_menhir_stack, _menhir_s, _v) in
      let _tok = _menhir_lexer _menhir_lexbuf in
      match (_tok : MenhirBasics.token) with
      | LBRACE ->
          let _tok = _menhir_lexer _menhir_lexbuf in
          (match (_tok : MenhirBasics.token) with
          | Ident _v_0 ->
              let _menhir_stack = MenhirCell0_Ident (_menhir_stack, _v_0) in
              let _tok = _menhir_lexer _menhir_lexbuf in
              (match (_tok : MenhirBasics.token) with
              | COMMA ->
                  let _tok = _menhir_lexer _menhir_lexbuf in
                  (match (_tok : MenhirBasics.token) with
                  | Ident _v_1 ->
                      _menhir_run_05 _menhir_stack _menhir_lexbuf _menhir_lexer _v_1 MenhirState04
                  | RBRACE ->
                      let _v_2 = _menhir_action_07 () in
                      _menhir_run_12 _menhir_stack _menhir_lexbuf _menhir_lexer _v_2
                  | _ ->
                      _eRR ())
              | _ ->
                  _eRR ())
          | _ ->
              _eRR ())
      | _ ->
          _eRR ()
  
  and _menhir_run_05 : type  ttv_stack. ttv_stack -> _ -> _ -> _ -> (ttv_stack, _menhir_box_entries) _menhir_state -> _menhir_box_entries =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s ->
      let _menhir_stack = MenhirCell1_Ident (_menhir_stack, _menhir_s, _v) in
      let _tok = _menhir_lexer _menhir_lexbuf in
      match (_tok : MenhirBasics.token) with
      | Equal_braced_string _v_0 ->
          let _menhir_stack = MenhirCell0_Equal_braced_string (_menhir_stack, _v_0) in
          let _tok = _menhir_lexer _menhir_lexbuf in
          (match (_tok : MenhirBasics.token) with
          | COMMA ->
              _menhir_run_07 _menhir_stack _menhir_lexbuf _menhir_lexer MenhirState06
          | Ident _ | RBRACE ->
              let _ = _menhir_action_09 () in
              _menhir_run_08 _menhir_stack _menhir_lexbuf _menhir_lexer _tok
          | _ ->
              _eRR ())
      | EQUAL ->
          let _tok = _menhir_lexer _menhir_lexbuf in
          (match (_tok : MenhirBasics.token) with
          | String _v_2 ->
              let _menhir_stack = MenhirCell0_String (_menhir_stack, _v_2) in
              let _tok = _menhir_lexer _menhir_lexbuf in
              (match (_tok : MenhirBasics.token) with
              | COMMA ->
                  _menhir_run_07 _menhir_stack _menhir_lexbuf _menhir_lexer MenhirState10
              | Ident _ | RBRACE ->
                  let _ = _menhir_action_09 () in
                  _menhir_run_11 _menhir_stack _menhir_lexbuf _menhir_lexer _tok
              | _ ->
                  _eRR ())
          | _ ->
              _eRR ())
      | _ ->
          _eRR ()
  
  and _menhir_run_07 : type  ttv_stack. ttv_stack -> _ -> _ -> (ttv_stack, _menhir_box_entries) _menhir_state -> _menhir_box_entries =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s ->
      let _tok = _menhir_lexer _menhir_lexbuf in
      let x = () in
      let _ = _menhir_action_10 x in
      _menhir_goto_option_COMMA_ _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s _tok
  
  and _menhir_goto_option_COMMA_ : type  ttv_stack. ttv_stack -> _ -> _ -> (ttv_stack, _menhir_box_entries) _menhir_state -> _ -> _menhir_box_entries =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s _tok ->
      match _menhir_s with
      | MenhirState10 ->
          _menhir_run_11 _menhir_stack _menhir_lexbuf _menhir_lexer _tok
      | MenhirState06 ->
          _menhir_run_08 _menhir_stack _menhir_lexbuf _menhir_lexer _tok
      | _ ->
          _menhir_fail ()
  
  and _menhir_run_11 : type  ttv_stack. (ttv_stack, _menhir_box_entries) _menhir_cell1_Ident _menhir_cell0_String -> _ -> _ -> _ -> _menhir_box_entries =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _tok ->
      let MenhirCell0_String (_menhir_stack, s) = _menhir_stack in
      let MenhirCell1_Ident (_menhir_stack, _menhir_s, n) = _menhir_stack in
      let _v = _menhir_action_03 n s in
      _menhir_goto_field _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok
  
  and _menhir_goto_field : type  ttv_stack. ttv_stack -> _ -> _ -> _ -> (ttv_stack, _menhir_box_entries) _menhir_state -> _ -> _menhir_box_entries =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok ->
      let _menhir_stack = MenhirCell1_field (_menhir_stack, _menhir_s, _v) in
      match (_tok : MenhirBasics.token) with
      | Ident _v_0 ->
          _menhir_run_05 _menhir_stack _menhir_lexbuf _menhir_lexer _v_0 MenhirState14
      | RBRACE ->
          let _v_1 = _menhir_action_07 () in
          _menhir_run_15 _menhir_stack _menhir_lexbuf _menhir_lexer _v_1
      | _ ->
          _eRR ()
  
  and _menhir_run_15 : type  ttv_stack. (ttv_stack, _menhir_box_entries) _menhir_cell1_field -> _ -> _ -> _ -> _menhir_box_entries =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _v ->
      let MenhirCell1_field (_menhir_stack, _menhir_s, x) = _menhir_stack in
      let xs = _v in
      let _v = _menhir_action_08 x xs in
      _menhir_goto_list_field_ _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s
  
  and _menhir_goto_list_field_ : type  ttv_stack. ttv_stack -> _ -> _ -> _ -> (ttv_stack, _menhir_box_entries) _menhir_state -> _menhir_box_entries =
    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
      | MenhirState04 ->
          _menhir_run_12 _menhir_stack _menhir_lexbuf _menhir_lexer _v
      | _ ->
          _menhir_fail ()
  
  and _menhir_run_12 : type  ttv_stack. (ttv_stack, _menhir_box_entries) _menhir_cell1_Entry_kind _menhir_cell0_Ident -> _ -> _ -> _ -> _menhir_box_entries =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _v ->
      let _tok = _menhir_lexer _menhir_lexbuf in
      let MenhirCell0_Ident (_menhir_stack, id) = _menhir_stack in
      let MenhirCell1_Entry_kind (_menhir_stack, _menhir_s, k) = _menhir_stack in
      let l = _v in
      let _v = _menhir_action_02 id k l in
      let _menhir_stack = MenhirCell1_entry (_menhir_stack, _menhir_s, _v) in
      match (_tok : MenhirBasics.token) with
      | Entry_kind _v_0 ->
          _menhir_run_01 _menhir_stack _menhir_lexbuf _menhir_lexer _v_0 MenhirState19
      | EOF ->
          let _v_1 = _menhir_action_05 () in
          _menhir_run_20 _menhir_stack _v_1
      | _ ->
          _eRR ()
  
  and _menhir_run_08 : type  ttv_stack. (ttv_stack, _menhir_box_entries) _menhir_cell1_Ident _menhir_cell0_Equal_braced_string -> _ -> _ -> _ -> _menhir_box_entries =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _tok ->
      let MenhirCell0_Equal_braced_string (_menhir_stack, s) = _menhir_stack in
      let MenhirCell1_Ident (_menhir_stack, _menhir_s, n) = _menhir_stack in
      let _v = _menhir_action_04 n s in
      _menhir_goto_field _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok
  
  let _menhir_run_00 : type  ttv_stack. ttv_stack -> _ -> _ -> _menhir_box_entries =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer ->
      let _tok = _menhir_lexer _menhir_lexbuf in
      match (_tok : MenhirBasics.token) with
      | Entry_kind _v ->
          _menhir_run_01 _menhir_stack _menhir_lexbuf _menhir_lexer _v MenhirState00
      | EOF ->
          let _v = _menhir_action_05 () in
          _menhir_run_16 _menhir_stack _v MenhirState00
      | _ ->
          _eRR ()
  
end

let entries =
  fun _menhir_lexer _menhir_lexbuf ->
    let _menhir_stack = () in
    let MenhirBox_entries v = _menhir_run_00 _menhir_stack _menhir_lexbuf _menhir_lexer in
    v