package binsec

  1. Overview
  2. Docs

doc/src/binsec_cli_bbsse/parser.ml.html

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

module MenhirBasics = struct
  
  exception Error
  
  let _eRR =
    fun _s ->
      raise Error
  
  type token = 
    | UNREACHABLE
    | SKIP
    | PROCESS
    | OPAQUE
    | IS
    | FALLTHROUGH
    | EXPECT
    | EOF
    | CLEAR
    | CALL
    | BRANCH
    | AT
    | ADDRESS of 
# 24 "src/cli/command/bbsse/parser.mly"
       (Z.t)
# 27 "src/cli/command/bbsse/parser.ml"
  
  
end

include MenhirBasics

type ('s, 'r) _menhir_state = 
  | MenhirState00 : ('s, _menhir_box_directives) _menhir_state
    (** State 00.
        Stack shape : <empty>.
        Start symbol: directives. *)

  | MenhirState18 : (('s, _menhir_box_directives) _menhir_cell1_directive, _menhir_box_directives) _menhir_state
    (** State 18.
        Stack shape : directive.
        Start symbol: directives. *)


and ('s, 'r) _menhir_cell1_directive = 
  | MenhirCell1_directive of 's * ('s, 'r) _menhir_state * (Types.Directive.t)

and _menhir_box_directives = 
  | MenhirBox_directives of (Types.Directive.t list) [@@unboxed]

let _menhir_action_01 =
  fun _1 _1_inlined1 _2 _3 addr ->
    let status =
      let _1 = _1_inlined1 in
      
# 48 "src/cli/command/bbsse/parser.mly"
    ( Types.Status.Opaque true )
# 59 "src/cli/command/bbsse/parser.ml"
      
    in
    let address = 
# 44 "src/cli/command/bbsse/parser.mly"
    ( Virtual_address.of_bigint addr )
# 65 "src/cli/command/bbsse/parser.ml"
     in
    (
# 37 "src/cli/command/bbsse/parser.mly"
    ( Types.Directive.ExpectAt (address, status) )
# 70 "src/cli/command/bbsse/parser.ml"
     : (Types.Directive.t))

let _menhir_action_02 =
  fun _1 _1_inlined1 _2 _3 addr ->
    let status =
      let _1 = _1_inlined1 in
      
# 50 "src/cli/command/bbsse/parser.mly"
    ( Types.Status.Opaque false )
# 80 "src/cli/command/bbsse/parser.ml"
      
    in
    let address = 
# 44 "src/cli/command/bbsse/parser.mly"
    ( Virtual_address.of_bigint addr )
# 86 "src/cli/command/bbsse/parser.ml"
     in
    (
# 37 "src/cli/command/bbsse/parser.mly"
    ( Types.Directive.ExpectAt (address, status) )
# 91 "src/cli/command/bbsse/parser.ml"
     : (Types.Directive.t))

let _menhir_action_03 =
  fun _1 _1_inlined1 _3 addr ->
    let status =
      let _1 = _1_inlined1 in
      
# 52 "src/cli/command/bbsse/parser.mly"
    ( Types.Status.Unreachable )
# 101 "src/cli/command/bbsse/parser.ml"
      
    in
    let address = 
# 44 "src/cli/command/bbsse/parser.mly"
    ( Virtual_address.of_bigint addr )
# 107 "src/cli/command/bbsse/parser.ml"
     in
    (
# 37 "src/cli/command/bbsse/parser.mly"
    ( Types.Directive.ExpectAt (address, status) )
# 112 "src/cli/command/bbsse/parser.ml"
     : (Types.Directive.t))

let _menhir_action_04 =
  fun _1 _1_inlined1 _3 addr ->
    let status =
      let _1 = _1_inlined1 in
      
# 54 "src/cli/command/bbsse/parser.mly"
    ( Types.Status.Clear )
# 122 "src/cli/command/bbsse/parser.ml"
      
    in
    let address = 
# 44 "src/cli/command/bbsse/parser.mly"
    ( Virtual_address.of_bigint addr )
# 128 "src/cli/command/bbsse/parser.ml"
     in
    (
# 37 "src/cli/command/bbsse/parser.mly"
    ( Types.Directive.ExpectAt (address, status) )
# 133 "src/cli/command/bbsse/parser.ml"
     : (Types.Directive.t))

let _menhir_action_05 =
  fun _1 addr ->
    let address = 
# 44 "src/cli/command/bbsse/parser.mly"
    ( Virtual_address.of_bigint addr )
# 141 "src/cli/command/bbsse/parser.ml"
     in
    (
# 39 "src/cli/command/bbsse/parser.mly"
    ( Types.Directive.SkipJump address )
# 146 "src/cli/command/bbsse/parser.ml"
     : (Types.Directive.t))

let _menhir_action_06 =
  fun _1 _2 _3 addr ->
    let address = 
# 44 "src/cli/command/bbsse/parser.mly"
    ( Virtual_address.of_bigint addr )
# 154 "src/cli/command/bbsse/parser.ml"
     in
    (
# 41 "src/cli/command/bbsse/parser.mly"
    ( Types.Directive.ProcessCall address )
# 159 "src/cli/command/bbsse/parser.ml"
     : (Types.Directive.t))

let _menhir_action_07 =
  fun _1 _2 ->
    (_1 : (Types.Directive.t list))

let _menhir_action_08 =
  fun () ->
    (
# 216 "<standard.mly>"
    ( [] )
# 171 "src/cli/command/bbsse/parser.ml"
     : (Types.Directive.t list))

let _menhir_action_09 =
  fun x xs ->
    (
# 219 "<standard.mly>"
    ( x :: xs )
# 179 "src/cli/command/bbsse/parser.ml"
     : (Types.Directive.t list))

let _menhir_print_token : token -> string =
  fun _tok ->
    match _tok with
    | UNREACHABLE ->
        "UNREACHABLE"
    | SKIP ->
        "SKIP"
    | PROCESS ->
        "PROCESS"
    | OPAQUE ->
        "OPAQUE"
    | IS ->
        "IS"
    | FALLTHROUGH ->
        "FALLTHROUGH"
    | EXPECT ->
        "EXPECT"
    | EOF ->
        "EOF"
    | CLEAR ->
        "CLEAR"
    | CALL ->
        "CALL"
    | BRANCH ->
        "BRANCH"
    | AT ->
        "AT"
    | ADDRESS _ ->
        "ADDRESS"

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_15 : type  ttv_stack. ttv_stack -> _ -> _menhir_box_directives =
    fun _menhir_stack _v ->
      let (_1, _2) = (_v, ()) in
      let _v = _menhir_action_07 _1 _2 in
      MenhirBox_directives _v
  
  let rec _menhir_run_19 : type  ttv_stack. (ttv_stack, _menhir_box_directives) _menhir_cell1_directive -> _ -> _menhir_box_directives =
    fun _menhir_stack _v ->
      let MenhirCell1_directive (_menhir_stack, _menhir_s, x) = _menhir_stack in
      let xs = _v in
      let _v = _menhir_action_09 x xs in
      _menhir_goto_list_directive_ _menhir_stack _v _menhir_s
  
  and _menhir_goto_list_directive_ : type  ttv_stack. ttv_stack -> _ -> (ttv_stack, _menhir_box_directives) _menhir_state -> _menhir_box_directives =
    fun _menhir_stack _v _menhir_s ->
      match _menhir_s with
      | MenhirState00 ->
          _menhir_run_15 _menhir_stack _v
      | MenhirState18 ->
          _menhir_run_19 _menhir_stack _v
  
  let rec _menhir_run_01 : type  ttv_stack. ttv_stack -> _ -> _ -> (ttv_stack, _menhir_box_directives) _menhir_state -> _menhir_box_directives =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s ->
      let _tok = _menhir_lexer _menhir_lexbuf in
      match (_tok : MenhirBasics.token) with
      | ADDRESS _v ->
          let _tok = _menhir_lexer _menhir_lexbuf in
          let (addr, _1) = (_v, ()) in
          let _v = _menhir_action_05 _1 addr in
          _menhir_goto_directive _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok
      | _ ->
          _eRR ()
  
  and _menhir_goto_directive : type  ttv_stack. ttv_stack -> _ -> _ -> _ -> (ttv_stack, _menhir_box_directives) _menhir_state -> _ -> _menhir_box_directives =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok ->
      let _menhir_stack = MenhirCell1_directive (_menhir_stack, _menhir_s, _v) in
      match (_tok : MenhirBasics.token) with
      | SKIP ->
          _menhir_run_01 _menhir_stack _menhir_lexbuf _menhir_lexer MenhirState18
      | PROCESS ->
          _menhir_run_03 _menhir_stack _menhir_lexbuf _menhir_lexer MenhirState18
      | EXPECT ->
          _menhir_run_07 _menhir_stack _menhir_lexbuf _menhir_lexer MenhirState18
      | EOF ->
          let _v_0 = _menhir_action_08 () in
          _menhir_run_19 _menhir_stack _v_0
      | _ ->
          _eRR ()
  
  and _menhir_run_03 : type  ttv_stack. ttv_stack -> _ -> _ -> (ttv_stack, _menhir_box_directives) _menhir_state -> _menhir_box_directives =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s ->
      let _tok = _menhir_lexer _menhir_lexbuf in
      match (_tok : MenhirBasics.token) with
      | CALL ->
          let _tok = _menhir_lexer _menhir_lexbuf in
          (match (_tok : MenhirBasics.token) with
          | AT ->
              let _tok = _menhir_lexer _menhir_lexbuf in
              (match (_tok : MenhirBasics.token) with
              | ADDRESS _v ->
                  let _tok = _menhir_lexer _menhir_lexbuf in
                  let (addr, _1, _3, _2) = (_v, (), (), ()) in
                  let _v = _menhir_action_06 _1 _2 _3 addr in
                  _menhir_goto_directive _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok
              | _ ->
                  _eRR ())
          | _ ->
              _eRR ())
      | _ ->
          _eRR ()
  
  and _menhir_run_07 : type  ttv_stack. ttv_stack -> _ -> _ -> (ttv_stack, _menhir_box_directives) _menhir_state -> _menhir_box_directives =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s ->
      let _tok = _menhir_lexer _menhir_lexbuf in
      match (_tok : MenhirBasics.token) with
      | ADDRESS _v ->
          let _tok = _menhir_lexer _menhir_lexbuf in
          (match (_tok : MenhirBasics.token) with
          | IS ->
              let _tok = _menhir_lexer _menhir_lexbuf in
              (match (_tok : MenhirBasics.token) with
              | UNREACHABLE ->
                  let _tok = _menhir_lexer _menhir_lexbuf in
                  let (addr, _1, _3, _1_inlined1) = (_v, (), (), ()) in
                  let _v = _menhir_action_03 _1 _1_inlined1 _3 addr in
                  _menhir_goto_directive _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok
              | OPAQUE ->
                  let _tok = _menhir_lexer _menhir_lexbuf in
                  (match (_tok : MenhirBasics.token) with
                  | FALLTHROUGH ->
                      let _tok = _menhir_lexer _menhir_lexbuf in
                      let (addr, _1, _3, _2, _1_inlined1) = (_v, (), (), (), ()) in
                      let _v = _menhir_action_02 _1 _1_inlined1 _2 _3 addr in
                      _menhir_goto_directive _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok
                  | BRANCH ->
                      let _tok = _menhir_lexer _menhir_lexbuf in
                      let (addr, _1, _3, _2, _1_inlined1) = (_v, (), (), (), ()) in
                      let _v = _menhir_action_01 _1 _1_inlined1 _2 _3 addr in
                      _menhir_goto_directive _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok
                  | _ ->
                      _eRR ())
              | CLEAR ->
                  let _tok = _menhir_lexer _menhir_lexbuf in
                  let (addr, _1, _3, _1_inlined1) = (_v, (), (), ()) in
                  let _v = _menhir_action_04 _1 _1_inlined1 _3 addr in
                  _menhir_goto_directive _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok
              | _ ->
                  _eRR ())
          | _ ->
              _eRR ())
      | _ ->
          _eRR ()
  
  let _menhir_run_00 : type  ttv_stack. ttv_stack -> _ -> _ -> _menhir_box_directives =
    fun _menhir_stack _menhir_lexbuf _menhir_lexer ->
      let _tok = _menhir_lexer _menhir_lexbuf in
      match (_tok : MenhirBasics.token) with
      | SKIP ->
          _menhir_run_01 _menhir_stack _menhir_lexbuf _menhir_lexer MenhirState00
      | PROCESS ->
          _menhir_run_03 _menhir_stack _menhir_lexbuf _menhir_lexer MenhirState00
      | EXPECT ->
          _menhir_run_07 _menhir_stack _menhir_lexbuf _menhir_lexer MenhirState00
      | EOF ->
          let _v = _menhir_action_08 () in
          _menhir_run_15 _menhir_stack _v
      | _ ->
          _eRR ()
  
end

let directives =
  fun _menhir_lexer _menhir_lexbuf ->
    let _menhir_stack = () in
    let MenhirBox_directives v = _menhir_run_00 _menhir_stack _menhir_lexbuf _menhir_lexer in
    v