ebnf 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
- # ebnf
1
+ # EBNF
2
2
 
3
3
  [EBNF][] parser and generic parser generator.
4
4
 
5
5
  ## Description
6
6
  This is a [Ruby][] implementation of an [EBNF][] and [BNF][] parser and parser generator.
7
- It parses [EBNF][] grammars to [BNF][], generates [First/Follow][] and [Branch][] tables for
7
+ It parses [EBNF][] grammars to [BNF][], generates [First/Follow and Branch][] tables for
8
8
  [LL(1)][] grammars, which can be used with the stream [Tokenizer][] and [LL(1) Parser][].
9
9
 
10
10
  Of note in this implementation is that the tokenizer and parser are streaming, so that they can
@@ -31,7 +31,7 @@ Generate [First/Follow][] rules for BNF grammars
31
31
 
32
32
  ebnf.first_follow(start_tokens)
33
33
 
34
- Generate [Branch][], terminal and [First/Follow][] tables as Ruby for parsing grammars
34
+ Generate Terminal, [First/Follow and Branch][] tables as Ruby for parsing grammars
35
35
 
36
36
  ebnf.to_ruby
37
37
 
@@ -134,9 +134,24 @@ The [EBNF][] variant used here is based on [W3C][] [EBNF][] as defined in the
134
134
  |
135
135
  )+
136
136
 
137
+ # # Acknowledgements
138
+ Much of this work, particularly the generic parser, is inspired by work originally done by
139
+ Tim Berners-Lee's Python [predictive parser](http://www.w3.org/2000/10/swap/grammar/predictiveParser.py).
140
+
141
+ The EBNF parser was inspired by Dan Connolly's
142
+ [EBNF to Turtle processor](http://www.w3.org/2000/10/swap/grammar/ebnf2turtle.py),
143
+ [EBNF to BNF Notation-3 rules](http://www.w3.org/2000/10/swap/grammar/ebnf2bnf.n3),
144
+ and [First Follow Notation-3 rules](http://www.w3.org/2000/10/swap/grammar/first_follow.n3).
145
+
146
+
137
147
  ## Documentation
138
148
  Full documentation available on [Rubydoc.info][EBNF doc].
139
149
 
150
+ ## Future Work
151
+ * Detect FIRST/FOLLOW and left-recursion conflicts.
152
+ * Generate HTML output of parser results.
153
+ * Better LL(1) parser tests
154
+
140
155
  ## Author
141
156
  * [Gregg Kellogg](http://github.com/gkellogg) - <http://greggkellogg.net/>
142
157
 
@@ -162,9 +177,8 @@ see <http://unlicense.org/> or the accompanying {file:UNLICENSE} file.
162
177
  [YARD-GS]: http://rubydoc.info/docs/yard/file/docs/GettingStarted.md
163
178
  [PDD]: http://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html
164
179
  [EBNF]: http://www.w3.org/TR/REC-xml/#sec-notation
165
- [EBNF doc]:
180
+ [EBNF doc]: http://rubydoc.info/github/gkellogg/ebnf/master/frames
166
181
  [First/Follow]: http://en.wikipedia.org/wiki/LL_parser#Constructing_an_LL.281.29_parsing_table
167
- [Branch]:
168
- [LL(1)]:
182
+ [LL(1)]: http://www.csd.uwo.ca/~moreno//CS447/Lectures/Syntax.html/node14.html
169
183
  [LL(1) Parser]: http://en.wikipedia.org/wiki/LL_parser
170
- [Tokenizer]:
184
+ [Tokenizer]: http://en.wikipedia.org/wiki/Lexical_analysis#Tokenizer
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.1.0
data/bin/ebnf CHANGED
@@ -1,6 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
- # ebnf2ttl --- Generate reasoned Turtle representation of EBNF input file
3
- # to be used in extracting parser branch tables (see gramLL1).
2
+ # ebnf --- Process EBNF to generate the following:
3
+ # * S-Expression
4
+ # * Turtle
5
+ # * Either of the above, transformed to BNF
6
+ # * And with First/Follow rules
4
7
 
5
8
  $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", 'lib')))
6
9
  require "bundler/setup"
@@ -9,6 +12,29 @@ require 'getoptlong'
9
12
  require 'ebnf'
10
13
  require 'sxp'
11
14
 
15
+ def dump_tables(grammarFile, ebnf, output, options)
16
+ ebnf.build_tables
17
+ unless output == STDOUT
18
+ output.puts "# This file is automatically generated by #{__FILE__}"
19
+ output.puts "# BRANCH derived from #{grammarFile}"
20
+ unless ebnf.errors.empty?
21
+ output.puts "# Note, tables completed with errors, may need to be resolved manually:"
22
+ #output.puts "# #{pp.conflicts.map{|c| c.join("\n# ")}.join("\n# ")}"
23
+ end
24
+ output.puts "module #{options.fetch(:mod_name, 'Branch')}"
25
+ output.puts " START = #{ebnf.start.inspect}"
26
+ output.puts
27
+ end
28
+ ebnf.outputTable(output, 'BRANCH', ebnf.branch, 1)
29
+ ebnf.outputTable(output, 'TERMINALS', ebnf.terminals, 1)
30
+ ebnf.outputTable(output, 'FIRST', ebnf.first, 1)
31
+ ebnf.outputTable(output, 'FOLLOW', ebnf.follow, 1)
32
+ unless output == STDOUT
33
+ output.puts "end"
34
+ end
35
+ ""
36
+ end
37
+
12
38
  options = {
13
39
  :format => :sxp,
14
40
  :prefix => "ttl",
@@ -17,37 +43,68 @@ options = {
17
43
 
18
44
  out = STDOUT
19
45
 
20
- opts = GetoptLong.new(
21
- ["--dbg", GetoptLong::NO_ARGUMENT],
22
- ["--bnf", GetoptLong::NO_ARGUMENT],
23
- ["--execute", "-e", GetoptLong::REQUIRED_ARGUMENT],
24
- ["--output", "-o", GetoptLong::REQUIRED_ARGUMENT],
25
- ["--format", "-f", GetoptLong::REQUIRED_ARGUMENT],
26
- ["--prefix", "-p", GetoptLong::REQUIRED_ARGUMENT],
27
- ["--namespace", "-n", GetoptLong::REQUIRED_ARGUMENT],
28
- ["--verbose", GetoptLong::NO_ARGUMENT]
29
- )
46
+ OPT_ARGS = [
47
+ ["--dbg", GetoptLong::NO_ARGUMENT, "Turn on debugging output"],
48
+ ["--bnf", GetoptLong::NO_ARGUMENT, "Transform EBNF to BNF"],
49
+ ["--evaluate","-e", GetoptLong::REQUIRED_ARGUMENT,"Evaluate argument as a JSON-LD document"],
50
+ ["--ll1", GetoptLong::REQUIRED_ARGUMENT,"Generate First/Follow rules, argument is start symbol"],
51
+ ["--format", "-f", GetoptLong::REQUIRED_ARGUMENT,"Specify output format one of ttl, sxp, or rb"],
52
+ ["--mod-name", GetoptLong::REQUIRED_ARGUMENT,"Module name used when creating ruby tables"],
53
+ ["--output", "-o", GetoptLong::REQUIRED_ARGUMENT,"Output to the specified file path"],
54
+ ["--prefix", "-p", GetoptLong::REQUIRED_ARGUMENT,"Prefix to use when generating Turtle"],
55
+ ["--progress", "-v", GetoptLong::NO_ARGUMENT, "Detail on execution"],
56
+ ["--namespace", "-n", GetoptLong::REQUIRED_ARGUMENT,"Namespace to use when generating Turtle"],
57
+ ["--help", "-?", GetoptLong::NO_ARGUMENT, "This message"]
58
+ ]
59
+ def usage
60
+ STDERR.puts %{#{$0} Version #{EBNF::VERSION}}
61
+ STDERR.puts %{Usage: #{$0} [options] file ...}
62
+ width = OPT_ARGS.map do |o|
63
+ l = o.first.length
64
+ l += o[1].length + 2 if o[1].is_a?(String)
65
+ l
66
+ end.max
67
+ OPT_ARGS.each do |o|
68
+ s = " %-*s " % [width, (o[1].is_a?(String) ? "#{o[0,2].join(', ')}" : o[0])]
69
+ s += o.last
70
+ STDERR.puts s
71
+ end
72
+ exit(1)
73
+ end
74
+
75
+ opts = GetoptLong.new(*OPT_ARGS.map {|o| o[0..-2]})
30
76
 
31
77
  opts.each do |opt, arg|
32
78
  case opt
33
79
  when '--dbg' then options[:debug] = true
34
80
  when '--bnf' then options[:bnf] = true
35
- when '--execute' then input = arg
81
+ when '--evaluate' then input = arg
36
82
  when '--format' then options[:format] = arg.to_sym
83
+ when '--ll1' then options[:ll1] = arg.to_sym
84
+ when '--mod-name' then options[:mod_name] = arg
37
85
  when '--output' then out = File.open(arg, "w")
38
86
  when '--prefix' then options[:prefix] = arg
39
87
  when '--namespace' then options[:namespace] = arg
40
- when '--verbose' then $verbose = true
88
+ when '--progress' then options[:progress] = true
89
+ when '--help' then usage
41
90
  end
42
91
  end
43
92
 
93
+ if options[:format] == :rb && !options[:ll1]
94
+ STDERR.puts "outputing in .rb format requires -ll"
95
+ exit(1)
96
+ end
97
+
44
98
  input = File.open(ARGV[0]) if ARGV[0]
45
99
 
46
- ebnf = EBNF.new(input || STDIN, options)
47
- ebnf = ebnf.make_bnf if options[:bnf]
100
+ ebnf = EBNF.parse(input || STDIN, options)
101
+ ebnf.make_bnf if options[:bnf] || options[:ll1]
102
+ ebnf.first_follow(options[:ll1]) if options[:ll1]
103
+
48
104
  res = case options[:format]
49
105
  when :sxp then ebnf.to_sxp
50
106
  when :ttl then ebnf.to_ttl(options[:prefix], options[:namespace])
107
+ when :rb then dump_tables(ARGV[0], ebnf, out, options)
51
108
  else ebnf.ast.inspect
52
109
  end
53
110
 
@@ -19,7 +19,7 @@
19
19
 
20
20
  [10] primary ::= HEX
21
21
  | RANGE
22
- | ENUM
22
+ | ENUM
23
23
  | O_RANGE
24
24
  | O_ENUM
25
25
  | STRING1
@@ -38,7 +38,7 @@
38
38
 
39
39
  [15] O_RANGE ::= '[^' CHAR '-' CHAR ']'
40
40
 
41
- [16] OENUM ::= '[^' CHAR+ ']'
41
+ [16] O_ENUM ::= '[^' CHAR+ ']'
42
42
 
43
43
  [17] STRING1 ::= '"' (CHAR - '"')* '"'
44
44
 
data/etc/ebnf.ll1 ADDED
@@ -0,0 +1,1010 @@
1
+ ((rule
2
+ _empty
3
+ "0"
4
+ (first _eps)
5
+ (follow
6
+ "("
7
+ ")"
8
+ "-"
9
+ "@pass"
10
+ "@terminals"
11
+ ENUM
12
+ HEX
13
+ O_ENUM
14
+ O_RANGE
15
+ RANGE
16
+ STRING1
17
+ STRING2
18
+ "["
19
+ _eof
20
+ "|"
21
+ )
22
+ (seq)
23
+ )
24
+ (pass @pass "0" (seq ()))
25
+ (rule
26
+ ebnf
27
+ "1"
28
+ (start #t)
29
+ (first
30
+ "("
31
+ "@pass"
32
+ "@terminals"
33
+ ENUM
34
+ HEX
35
+ O_ENUM
36
+ O_RANGE
37
+ RANGE
38
+ STRING1
39
+ STRING2
40
+ "["
41
+ _eps
42
+ )
43
+ (follow _eof)
44
+ (alt _empty _ebnf_star)
45
+ )
46
+ (rule
47
+ _ebnf_star
48
+ "1*"
49
+ (first
50
+ "("
51
+ "@pass"
52
+ "@terminals"
53
+ ENUM
54
+ HEX
55
+ O_ENUM
56
+ O_RANGE
57
+ RANGE
58
+ STRING1
59
+ STRING2
60
+ "["
61
+ )
62
+ (follow _eof)
63
+ (seq _ebnf_1 ebnf)
64
+ )
65
+ (rule
66
+ __ebnf_star_comp
67
+ "1*.comp"
68
+ (first
69
+ "("
70
+ "@pass"
71
+ "@terminals"
72
+ ENUM
73
+ HEX
74
+ O_ENUM
75
+ O_RANGE
76
+ RANGE
77
+ STRING1
78
+ STRING2
79
+ "["
80
+ _eps
81
+ )
82
+ (follow _eof)
83
+ (seq ebnf)
84
+ )
85
+ (rule
86
+ _ebnf_1
87
+ "1.1"
88
+ (first
89
+ "("
90
+ "@pass"
91
+ "@terminals"
92
+ ENUM
93
+ HEX
94
+ O_ENUM
95
+ O_RANGE
96
+ RANGE
97
+ STRING1
98
+ STRING2
99
+ "["
100
+ )
101
+ (follow
102
+ "("
103
+ "@pass"
104
+ "@terminals"
105
+ ENUM
106
+ HEX
107
+ O_ENUM
108
+ O_RANGE
109
+ RANGE
110
+ STRING1
111
+ STRING2
112
+ "["
113
+ )
114
+ (alt declaration rule)
115
+ )
116
+ (rule
117
+ declaration
118
+ "2"
119
+ (first
120
+ "("
121
+ "@pass"
122
+ "@terminals"
123
+ ENUM
124
+ HEX
125
+ O_ENUM
126
+ O_RANGE
127
+ RANGE
128
+ STRING1
129
+ STRING2
130
+ )
131
+ (follow
132
+ "("
133
+ "@pass"
134
+ "@terminals"
135
+ ENUM
136
+ HEX
137
+ O_ENUM
138
+ O_RANGE
139
+ RANGE
140
+ STRING1
141
+ STRING2
142
+ "["
143
+ )
144
+ (alt "@terminals" "@pass")
145
+ )
146
+ (rule
147
+ rule
148
+ "3"
149
+ (first "[")
150
+ (follow
151
+ "("
152
+ "@pass"
153
+ "@terminals"
154
+ ENUM
155
+ HEX
156
+ O_ENUM
157
+ O_RANGE
158
+ RANGE
159
+ STRING1
160
+ STRING2
161
+ "["
162
+ )
163
+ (seq lhs "::=" expression)
164
+ )
165
+ (rule
166
+ _rule_comp
167
+ "3.comp"
168
+ (first "::=")
169
+ (follow
170
+ "("
171
+ "@pass"
172
+ "@terminals"
173
+ ENUM
174
+ HEX
175
+ O_ENUM
176
+ O_RANGE
177
+ RANGE
178
+ STRING1
179
+ STRING2
180
+ "["
181
+ )
182
+ (seq "::=" expression)
183
+ )
184
+ (rule
185
+ __rule_comp_comp
186
+ "3.comp.comp"
187
+ (first
188
+ "("
189
+ ENUM
190
+ HEX
191
+ O_ENUM
192
+ O_RANGE
193
+ RANGE
194
+ STRING1
195
+ STRING2
196
+ )
197
+ (follow
198
+ "("
199
+ "@pass"
200
+ "@terminals"
201
+ ENUM
202
+ HEX
203
+ O_ENUM
204
+ O_RANGE
205
+ RANGE
206
+ STRING1
207
+ STRING2
208
+ "["
209
+ )
210
+ (seq expression)
211
+ )
212
+ (rule
213
+ lhs
214
+ "4"
215
+ (first "[")
216
+ (follow "::=")
217
+ (seq "[" SYMBOL "]" SYMBOL)
218
+ )
219
+ (rule
220
+ _lhs_comp
221
+ "4.comp"
222
+ (first SYMBOL)
223
+ (follow "::=")
224
+ (seq SYMBOL "]" SYMBOL)
225
+ )
226
+ (rule
227
+ __lhs_comp_comp
228
+ "4.comp.comp"
229
+ (first "]")
230
+ (follow "::=")
231
+ (seq "]" SYMBOL)
232
+ )
233
+ (rule
234
+ ___lhs_comp_comp_comp
235
+ "4.comp.comp.comp"
236
+ (first SYMBOL)
237
+ (follow "::=")
238
+ (seq SYMBOL)
239
+ )
240
+ (rule
241
+ expression
242
+ "5"
243
+ (first
244
+ "("
245
+ ENUM
246
+ HEX
247
+ O_ENUM
248
+ O_RANGE
249
+ RANGE
250
+ STRING1
251
+ STRING2
252
+ )
253
+ (follow
254
+ "("
255
+ ")"
256
+ "@pass"
257
+ "@terminals"
258
+ ENUM
259
+ HEX
260
+ O_ENUM
261
+ O_RANGE
262
+ RANGE
263
+ STRING1
264
+ STRING2
265
+ "["
266
+ )
267
+ (seq alt)
268
+ )
269
+ (rule
270
+ alt
271
+ "6"
272
+ (first
273
+ "("
274
+ ENUM
275
+ HEX
276
+ O_ENUM
277
+ O_RANGE
278
+ RANGE
279
+ STRING1
280
+ STRING2
281
+ )
282
+ (follow
283
+ "("
284
+ ")"
285
+ "@pass"
286
+ "@terminals"
287
+ ENUM
288
+ HEX
289
+ O_ENUM
290
+ O_RANGE
291
+ RANGE
292
+ STRING1
293
+ STRING2
294
+ "["
295
+ )
296
+ (seq seq _alt_1)
297
+ )
298
+ (rule
299
+ _alt_1
300
+ "6.1"
301
+ (first
302
+ "("
303
+ ENUM
304
+ HEX
305
+ O_ENUM
306
+ O_RANGE
307
+ RANGE
308
+ STRING1
309
+ STRING2
310
+ _eps
311
+ "|"
312
+ )
313
+ (follow
314
+ "("
315
+ ")"
316
+ "@pass"
317
+ "@terminals"
318
+ ENUM
319
+ HEX
320
+ O_ENUM
321
+ O_RANGE
322
+ RANGE
323
+ STRING1
324
+ STRING2
325
+ "["
326
+ )
327
+ (alt _empty __alt_1_star)
328
+ )
329
+ (rule
330
+ __alt_1_star
331
+ "6.1*"
332
+ (first "|")
333
+ (follow
334
+ "("
335
+ ")"
336
+ "@pass"
337
+ "@terminals"
338
+ ENUM
339
+ HEX
340
+ O_ENUM
341
+ O_RANGE
342
+ RANGE
343
+ STRING1
344
+ STRING2
345
+ "["
346
+ )
347
+ (seq __alt_1_1 _alt_1)
348
+ )
349
+ (rule
350
+ ___alt_1_star_comp
351
+ "6.1*.comp"
352
+ (first
353
+ "("
354
+ ENUM
355
+ HEX
356
+ O_ENUM
357
+ O_RANGE
358
+ RANGE
359
+ STRING1
360
+ STRING2
361
+ _eps
362
+ "|"
363
+ )
364
+ (follow
365
+ "("
366
+ ")"
367
+ "@pass"
368
+ "@terminals"
369
+ ENUM
370
+ HEX
371
+ O_ENUM
372
+ O_RANGE
373
+ RANGE
374
+ STRING1
375
+ STRING2
376
+ "["
377
+ )
378
+ (seq _alt_1)
379
+ )
380
+ (rule
381
+ __alt_1_1
382
+ "6.1.1"
383
+ (first "|")
384
+ (follow
385
+ "("
386
+ ENUM
387
+ HEX
388
+ O_ENUM
389
+ O_RANGE
390
+ RANGE
391
+ STRING1
392
+ STRING2
393
+ "|"
394
+ )
395
+ (seq "|" seq)
396
+ )
397
+ (rule
398
+ ___alt_1_1_comp
399
+ "6.1.1.comp"
400
+ (first
401
+ "("
402
+ ENUM
403
+ HEX
404
+ O_ENUM
405
+ O_RANGE
406
+ RANGE
407
+ STRING1
408
+ STRING2
409
+ )
410
+ (follow
411
+ "("
412
+ ENUM
413
+ HEX
414
+ O_ENUM
415
+ O_RANGE
416
+ RANGE
417
+ STRING1
418
+ STRING2
419
+ "|"
420
+ )
421
+ (seq seq)
422
+ )
423
+ (rule
424
+ _alt_comp
425
+ "6.comp"
426
+ (first
427
+ "("
428
+ ENUM
429
+ HEX
430
+ O_ENUM
431
+ O_RANGE
432
+ RANGE
433
+ STRING1
434
+ STRING2
435
+ _eps
436
+ "|"
437
+ )
438
+ (follow
439
+ "("
440
+ ")"
441
+ "@pass"
442
+ "@terminals"
443
+ ENUM
444
+ HEX
445
+ O_ENUM
446
+ O_RANGE
447
+ RANGE
448
+ STRING1
449
+ STRING2
450
+ "["
451
+ )
452
+ (seq _alt_1)
453
+ )
454
+ (rule
455
+ seq
456
+ "7"
457
+ (first
458
+ "("
459
+ ENUM
460
+ HEX
461
+ O_ENUM
462
+ O_RANGE
463
+ RANGE
464
+ STRING1
465
+ STRING2
466
+ )
467
+ (follow
468
+ "("
469
+ ")"
470
+ "-"
471
+ "@pass"
472
+ "@terminals"
473
+ ENUM
474
+ HEX
475
+ O_ENUM
476
+ O_RANGE
477
+ RANGE
478
+ STRING1
479
+ STRING2
480
+ "["
481
+ _eof
482
+ "|"
483
+ )
484
+ (seq diff _seq_1)
485
+ )
486
+ (rule
487
+ _seq_1
488
+ "7.1"
489
+ (first
490
+ "("
491
+ ENUM
492
+ HEX
493
+ O_ENUM
494
+ O_RANGE
495
+ RANGE
496
+ STRING1
497
+ STRING2
498
+ _eps
499
+ )
500
+ (follow
501
+ "("
502
+ ")"
503
+ "-"
504
+ "@pass"
505
+ "@terminals"
506
+ ENUM
507
+ HEX
508
+ O_ENUM
509
+ O_RANGE
510
+ RANGE
511
+ STRING1
512
+ STRING2
513
+ "["
514
+ _eof
515
+ "|"
516
+ )
517
+ (alt _empty __seq_1_star)
518
+ )
519
+ (rule
520
+ __seq_1_star
521
+ "7.1*"
522
+ (first
523
+ "("
524
+ ENUM
525
+ HEX
526
+ O_ENUM
527
+ O_RANGE
528
+ RANGE
529
+ STRING1
530
+ STRING2
531
+ )
532
+ (follow
533
+ "("
534
+ ")"
535
+ "-"
536
+ "@pass"
537
+ "@terminals"
538
+ ENUM
539
+ HEX
540
+ O_ENUM
541
+ O_RANGE
542
+ RANGE
543
+ STRING1
544
+ STRING2
545
+ "["
546
+ _eof
547
+ "|"
548
+ )
549
+ (seq diff _seq_1)
550
+ )
551
+ (rule
552
+ ___seq_1_star_comp
553
+ "7.1*.comp"
554
+ (first
555
+ "("
556
+ ENUM
557
+ HEX
558
+ O_ENUM
559
+ O_RANGE
560
+ RANGE
561
+ STRING1
562
+ STRING2
563
+ _eps
564
+ )
565
+ (follow
566
+ "("
567
+ ")"
568
+ "-"
569
+ "@pass"
570
+ "@terminals"
571
+ ENUM
572
+ HEX
573
+ O_ENUM
574
+ O_RANGE
575
+ RANGE
576
+ STRING1
577
+ STRING2
578
+ "["
579
+ _eof
580
+ "|"
581
+ )
582
+ (seq _seq_1)
583
+ )
584
+ (rule
585
+ _seq_comp
586
+ "7.comp"
587
+ (first
588
+ "("
589
+ ENUM
590
+ HEX
591
+ O_ENUM
592
+ O_RANGE
593
+ RANGE
594
+ STRING1
595
+ STRING2
596
+ _eps
597
+ )
598
+ (follow
599
+ "("
600
+ ")"
601
+ "-"
602
+ "@pass"
603
+ "@terminals"
604
+ ENUM
605
+ HEX
606
+ O_ENUM
607
+ O_RANGE
608
+ RANGE
609
+ STRING1
610
+ STRING2
611
+ "["
612
+ _eof
613
+ "|"
614
+ )
615
+ (seq _seq_1)
616
+ )
617
+ (rule
618
+ diff
619
+ "8"
620
+ (first
621
+ "("
622
+ ENUM
623
+ HEX
624
+ O_ENUM
625
+ O_RANGE
626
+ RANGE
627
+ STRING1
628
+ STRING2
629
+ )
630
+ (follow
631
+ "("
632
+ ENUM
633
+ HEX
634
+ O_ENUM
635
+ O_RANGE
636
+ RANGE
637
+ STRING1
638
+ STRING2
639
+ )
640
+ (seq postfix _diff_1)
641
+ )
642
+ (rule
643
+ _diff_1
644
+ "8.1"
645
+ (first
646
+ "("
647
+ "-"
648
+ ENUM
649
+ HEX
650
+ O_ENUM
651
+ O_RANGE
652
+ RANGE
653
+ STRING1
654
+ STRING2
655
+ _eps
656
+ )
657
+ (follow
658
+ "("
659
+ ENUM
660
+ HEX
661
+ O_ENUM
662
+ O_RANGE
663
+ RANGE
664
+ STRING1
665
+ STRING2
666
+ )
667
+ (alt _empty __diff_1_star)
668
+ )
669
+ (rule
670
+ __diff_1_star
671
+ "8.1*"
672
+ (first "-")
673
+ (follow
674
+ "("
675
+ ENUM
676
+ HEX
677
+ O_ENUM
678
+ O_RANGE
679
+ RANGE
680
+ STRING1
681
+ STRING2
682
+ )
683
+ (seq __diff_1_1 _diff_1)
684
+ )
685
+ (rule
686
+ ___diff_1_star_comp
687
+ "8.1*.comp"
688
+ (first
689
+ "("
690
+ "-"
691
+ ENUM
692
+ HEX
693
+ O_ENUM
694
+ O_RANGE
695
+ RANGE
696
+ STRING1
697
+ STRING2
698
+ _eps
699
+ )
700
+ (follow
701
+ "("
702
+ ENUM
703
+ HEX
704
+ O_ENUM
705
+ O_RANGE
706
+ RANGE
707
+ STRING1
708
+ STRING2
709
+ )
710
+ (seq _diff_1)
711
+ )
712
+ (rule
713
+ __diff_1_1
714
+ "8.1.1"
715
+ (first "-")
716
+ (follow
717
+ "("
718
+ "-"
719
+ ENUM
720
+ HEX
721
+ O_ENUM
722
+ O_RANGE
723
+ RANGE
724
+ STRING1
725
+ STRING2
726
+ )
727
+ (seq "-" postfix)
728
+ )
729
+ (rule
730
+ ___diff_1_1_comp
731
+ "8.1.1.comp"
732
+ (first
733
+ "("
734
+ ENUM
735
+ HEX
736
+ O_ENUM
737
+ O_RANGE
738
+ RANGE
739
+ STRING1
740
+ STRING2
741
+ )
742
+ (follow
743
+ "("
744
+ "-"
745
+ ENUM
746
+ HEX
747
+ O_ENUM
748
+ O_RANGE
749
+ RANGE
750
+ STRING1
751
+ STRING2
752
+ )
753
+ (seq postfix)
754
+ )
755
+ (rule
756
+ _diff_comp
757
+ "8.comp"
758
+ (first
759
+ "("
760
+ "-"
761
+ ENUM
762
+ HEX
763
+ O_ENUM
764
+ O_RANGE
765
+ RANGE
766
+ STRING1
767
+ STRING2
768
+ _eps
769
+ )
770
+ (follow
771
+ "("
772
+ ENUM
773
+ HEX
774
+ O_ENUM
775
+ O_RANGE
776
+ RANGE
777
+ STRING1
778
+ STRING2
779
+ )
780
+ (seq _diff_1)
781
+ )
782
+ (rule
783
+ postfix
784
+ "9"
785
+ (first
786
+ "("
787
+ ENUM
788
+ HEX
789
+ O_ENUM
790
+ O_RANGE
791
+ RANGE
792
+ STRING1
793
+ STRING2
794
+ )
795
+ (follow
796
+ "("
797
+ "-"
798
+ ENUM
799
+ HEX
800
+ O_ENUM
801
+ O_RANGE
802
+ RANGE
803
+ STRING1
804
+ STRING2
805
+ )
806
+ (seq primary _postfix_1)
807
+ )
808
+ (rule
809
+ _postfix_1
810
+ "9.1"
811
+ (first
812
+ "("
813
+ ENUM
814
+ HEX
815
+ O_ENUM
816
+ O_RANGE
817
+ RANGE
818
+ STRING1
819
+ STRING2
820
+ _eps
821
+ )
822
+ (follow
823
+ "("
824
+ "-"
825
+ ENUM
826
+ HEX
827
+ O_ENUM
828
+ O_RANGE
829
+ RANGE
830
+ STRING1
831
+ STRING2
832
+ )
833
+ (alt _empty (range "?*+"))
834
+ )
835
+ (rule
836
+ _postfix_comp
837
+ "9.comp"
838
+ (first
839
+ "("
840
+ ENUM
841
+ HEX
842
+ O_ENUM
843
+ O_RANGE
844
+ RANGE
845
+ STRING1
846
+ STRING2
847
+ _eps
848
+ )
849
+ (follow
850
+ "("
851
+ "-"
852
+ ENUM
853
+ HEX
854
+ O_ENUM
855
+ O_RANGE
856
+ RANGE
857
+ STRING1
858
+ STRING2
859
+ )
860
+ (seq _postfix_1)
861
+ )
862
+ (rule
863
+ primary
864
+ "10"
865
+ (first
866
+ "("
867
+ ENUM
868
+ HEX
869
+ O_ENUM
870
+ O_RANGE
871
+ RANGE
872
+ STRING1
873
+ STRING2
874
+ )
875
+ (follow
876
+ "("
877
+ ENUM
878
+ HEX
879
+ O_ENUM
880
+ O_RANGE
881
+ RANGE
882
+ STRING1
883
+ STRING2
884
+ )
885
+ (alt
886
+ HEX
887
+ RANGE
888
+ ENUM
889
+ O_RANGE
890
+ O_ENUM
891
+ STRING1
892
+ STRING2
893
+ _primary_1
894
+ )
895
+ )
896
+ (rule
897
+ _primary_1
898
+ "10.1"
899
+ (first "(")
900
+ (follow
901
+ "("
902
+ ENUM
903
+ HEX
904
+ O_ENUM
905
+ O_RANGE
906
+ RANGE
907
+ STRING1
908
+ STRING2
909
+ )
910
+ (seq "(" expression ")")
911
+ )
912
+ (rule
913
+ __primary_1_comp
914
+ "10.1.comp"
915
+ (first
916
+ "("
917
+ ENUM
918
+ HEX
919
+ O_ENUM
920
+ O_RANGE
921
+ RANGE
922
+ STRING1
923
+ STRING2
924
+ )
925
+ (follow
926
+ "("
927
+ ENUM
928
+ HEX
929
+ O_ENUM
930
+ O_RANGE
931
+ RANGE
932
+ STRING1
933
+ STRING2
934
+ )
935
+ (seq expression ")")
936
+ )
937
+ (rule
938
+ ___primary_1_comp_comp
939
+ "10.1.comp.comp"
940
+ (first ")")
941
+ (follow
942
+ "("
943
+ ENUM
944
+ HEX
945
+ O_ENUM
946
+ O_RANGE
947
+ RANGE
948
+ STRING1
949
+ STRING2
950
+ )
951
+ (seq ")")
952
+ )
953
+ (terminal
954
+ SYMBOL
955
+ "11"
956
+ (plus
957
+ (alt
958
+ (range "a-z")
959
+ (range "A-Z")
960
+ (range "0-9")
961
+ "_"
962
+ )
963
+ )
964
+ )
965
+ (terminal
966
+ HEX
967
+ "12"
968
+ (seq
969
+ "#x"
970
+ (plus
971
+ (alt (range "0-9") (range "a-f") (range "A-F"))
972
+ )
973
+ )
974
+ )
975
+ (terminal
976
+ RANGE
977
+ "13"
978
+ (seq "[" CHAR "-" CHAR "]")
979
+ )
980
+ (terminal ENUM "14" (seq "[" (plus CHAR) "]"))
981
+ (terminal
982
+ O_RANGE
983
+ "15"
984
+ (seq "[^" CHAR "-" CHAR "]")
985
+ )
986
+ (terminal
987
+ O_ENUM
988
+ "16"
989
+ (seq "[^" (plus CHAR) "]")
990
+ )
991
+ (terminal
992
+ STRING1
993
+ "17"
994
+ (seq "\"" (star (diff CHAR "\"")) "\"")
995
+ )
996
+ (terminal
997
+ STRING2
998
+ "18"
999
+ (seq "'" (star (diff CHAR "'")) "'")
1000
+ )
1001
+ (terminal
1002
+ CHAR
1003
+ "19"
1004
+ (alt
1005
+ HEX
1006
+ (seq "\\\\" (range "\\\\trn'\""))
1007
+ (range "^\\t\\r\\n'\"")
1008
+ )
1009
+ )
1010
+ )