Module: Rattler::Grammar::Metagrammar

Includes:
Parsers
Included in:
GrammarParser
Defined in:
lib/rattler/grammar/metagrammar.rb

Instance Method Summary collapse

Methods included from Parsers

define

Instance Method Details

#match_attributedObject



206
207
208
# File 'lib/rattler/grammar/metagrammar.rb', line 206

def match_attributed #:nodoc:
  memoize_lr :match_attributed!
end

#match_attributed!Object



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
# File 'lib/rattler/grammar/metagrammar.rb', line 211

def match_attributed! #:nodoc:
  begin
    p0 = @scanner.pos
    begin
      (r0_0 = ((r = match(:attributed)) ? [r] : [])) &&
      @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?><)/) &&
      (r0_1 = ((r = begin
        @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>(?>[[:lower:]])(?>(?>[[:alnum:]_])*))|(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>(?>(?>(?>[[:upper:]])(?>(?>[[:alnum:]_])*)(?>::))*)(?>[[:upper:]])(?>(?>[[:alnum:]_])*)))(?>(?>(?>\.)(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>(?>[[:lower:]])(?>(?>[[:alnum:]_])*))))?))/) &&
        @scanner[1]
      end) ? [r] : [])) &&
      (r0_2 = ((r = begin
        begin
          @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>")(?>(?>(?>\\)(?>.)|[^"])*)(?>"))/) &&
          @scanner[1]
        end ||
        begin
          @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>')(?>(?>(?>\\)(?>.)|[^'])*)(?>'))/) &&
          @scanner[1]
        end ||
        begin
          @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>%\()(?>(?>(?>\\)(?>.)|[^)])*)(?>\)))/) &&
          @scanner[1]
        end ||
        begin
          @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>%\{)(?>(?>(?>\\)(?>.)|[^}])*)(?>\}))/) &&
          @scanner[1]
        end ||
        begin
          @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>%\[)(?>(?>(?>\\)(?>.)|[^\]])*)(?>\]))/) &&
          @scanner[1]
        end ||
        begin
          @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>%<)(?>(?>(?>\\)(?>.)|[^>])*)(?>>))/) &&
          @scanner[1]
        end ||
        begin
          p1 = @scanner.pos
          begin
            @scanner.skip(/(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*/) &&
            begin
              p2 = @scanner.pos
              begin
                @scanner.skip(/%/) &&
                (r2_0 = @scanner.scan(/[[:punct:]]/)) &&
                begin
                  while begin
                    @scanner.skip(/(?>\\)(?>.)/) ||
                    begin
                      p3 = @scanner.pos
                      begin
                        @scanner.skip(/(?!#{r2_0})/) &&
                        @scanner.skip(/./) &&
                        true
                      end || begin
                        @scanner.pos = p3
                        false
                      end
                    end
                  end; end
                  true
                end &&
                @scanner.skip(/#{r2_0}/) &&
                @scanner.string[p2...(@scanner.pos)]
              end || begin
                @scanner.pos = p2
                false
              end
            end
          end || begin
            @scanner.pos = p1
            false
          end
        end
      end) ? [r] : [])) &&
      @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>>)/) &&
      DispatchAction.parsed([r0_0, r0_1, r0_2])
    end || begin
      @scanner.pos = p0
      false
    end
  end ||
  begin
    p0 = @scanner.pos
    begin
      (r0_0 = ((r = match(:attributed)) ? [r] : [])) &&
      (r0_1 = begin
        @scanner.skip(/(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>\{))(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>(?>\{)(?>(?>[^}])*)(?>\})|[^{}])*))(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>\}))/) &&
        @scanner[1]
      end) &&
      DirectAction.parsed([r0_0, r0_1])
    end || begin
      @scanner.pos = p0
      false
    end
  end ||
  begin
    p0 = @scanner.pos
    begin
      (r0_0 = ((r = match(:attributed)) ? [r] : [])) &&
      (r0_1 = begin
        @scanner.skip(/(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>~))(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>\{))(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>(?>\{)(?>(?>[^}])*)(?>\})|[^{}])*))(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>\}))/) &&
        @scanner[1]
      end) &&
      SideEffect.parsed([r0_0, r0_1])
    end || begin
      @scanner.pos = p0
      false
    end
  end ||
  begin
    p0 = @scanner.pos
    begin
      (r0_0 = ((r = match(:attributed)) ? [r] : [])) &&
      (r0_1 = begin
        @scanner.skip(/(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>&))(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>\{))(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>(?>\{)(?>(?>[^}])*)(?>\})|[^{}])*))(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>\}))/) &&
        @scanner[1]
      end) &&
      SemanticAssert.parsed([r0_0, r0_1])
    end || begin
      @scanner.pos = p0
      false
    end
  end ||
  begin
    p0 = @scanner.pos
    begin
      (r0_0 = ((r = match(:attributed)) ? [r] : [])) &&
      (r0_1 = begin
        @scanner.skip(/(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>!))(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>\{))(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>(?>\{)(?>(?>[^}])*)(?>\})|[^{}])*))(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>\}))/) &&
        @scanner[1]
      end) &&
      SemanticDisallow.parsed([r0_0, r0_1])
    end || begin
      @scanner.pos = p0
      false
    end
  end ||
  match(:attributed_terms)
end

#match_attributed_termsObject



352
353
354
# File 'lib/rattler/grammar/metagrammar.rb', line 352

def match_attributed_terms #:nodoc:
  memoize_lr :match_attributed_terms!
end

#match_attributed_terms!Object



357
358
359
360
361
362
363
364
365
366
367
368
369
370
# File 'lib/rattler/grammar/metagrammar.rb', line 357

def match_attributed_terms! #:nodoc:
  begin
    p0 = @scanner.pos
    begin
      (r0_0 = match(:attributed)) &&
      (r0_1 = match(:term)) &&
      Sequence.parsed(select_captures([r0_0, r0_1]))
    end || begin
      @scanner.pos = p0
      false
    end
  end ||
  match(:terms)
end

#match_expressionObject



184
185
186
# File 'lib/rattler/grammar/metagrammar.rb', line 184

def match_expression #:nodoc:
  memoize_lr :match_expression!
end

#match_expression!Object



189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/rattler/grammar/metagrammar.rb', line 189

def match_expression! #:nodoc:
  begin
    p0 = @scanner.pos
    begin
      (r0_0 = match(:expression)) &&
      @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>\/)/) &&
      (r0_1 = match(:attributed)) &&
      Choice.parsed(select_captures([r0_0, r0_1]))
    end || begin
      @scanner.pos = p0
      false
    end
  end ||
  match(:attributed)
end

#match_grammarObject



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
# File 'lib/rattler/grammar/metagrammar.rb', line 16

def match_grammar #:nodoc:
  p0 = @scanner.pos
  begin
    (r0_0 = begin
      p1 = @scanner.pos
      begin
        (r1_0 = begin
          a0 = []
          while r = begin
            @scanner.skip(/(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>(?>require)(?![[:alnum:]_])))(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>(?!(?>(?>[[:blank:]])*)(?>\z|;|(?>(?>\r)?)(?>\n)|(?>\#)(?>(?>[^\n])*)))(?>.))+))(?>(?>(?>[[:blank:]])*)(?>\z|;|(?>(?>\r)?)(?>\n)|(?>\#)(?>(?>[^\n])*)))/) &&
            @scanner[1]
          end
            a0 << r
          end
          ({ :requires => select_captures(a0) })
        end) &&
        (r1_1 = ((r = begin
          begin
            p2 = @scanner.pos
            begin
              (r2_0 = begin
                @scanner.skip(/(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>(?>parser)(?![[:alnum:]_])))(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>(?>(?>[[:upper:]])(?>(?>[[:alnum:]_])*)(?>::))*)(?>[[:upper:]])(?>(?>[[:alnum:]_])*)))/) &&
                @scanner[1]
              end) &&
              (r2_1 = ((r = begin
                @scanner.skip(/(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?><))(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>(?>(?>[[:upper:]])(?>(?>[[:alnum:]_])*)(?>::))*)(?>[[:upper:]])(?>(?>[[:alnum:]_])*)))/) &&
                @scanner[1]
              end) ? [r] : [])) &&
              @scanner.skip(/(?>(?>(?>[[:blank:]])*)(?>\z|;|(?>(?>\r)?)(?>\n)|(?>\#)(?>(?>[^\n])*)))/) &&
              (parser_decl r2_0, r2_1)
            end || begin
              @scanner.pos = p2
              false
            end
          end ||
          begin
            @scanner.skip(/(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>(?>grammar)(?![[:alnum:]_])))(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>(?>(?>[[:upper:]])(?>(?>[[:alnum:]_])*)(?>::))*)(?>[[:upper:]])(?>(?>[[:alnum:]_])*)))(?>(?>(?>[[:blank:]])*)(?>\z|;|(?>(?>\r)?)(?>\n)|(?>\#)(?>(?>[^\n])*)))/) &&
            ({ :grammar_name => @scanner[1] })
          end
        end) ? [r] : [])) &&
        (r1_2 = begin
          a0 = []
          while r = begin
            @scanner.skip(/(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>(?>include)(?![[:alnum:]_])))(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>(?>(?>[[:upper:]])(?>(?>[[:alnum:]_])*)(?>::))*)(?>[[:upper:]])(?>(?>[[:alnum:]_])*)))(?>(?>(?>[[:blank:]])*)(?>\z|;|(?>(?>\r)?)(?>\n)|(?>\#)(?>(?>[^\n])*)))/) &&
            @scanner[1]
          end
            a0 << r
          end
          ({ :includes => select_captures(a0) })
        end) &&
        (heading r1_0, r1_1, r1_2)
      end || begin
        @scanner.pos = p1
        false
      end
    end) &&
    (r0_1 = begin
      a0 = []
      while r = begin
        begin
          p1 = @scanner.pos
          begin
            @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>(?>%whitespace)(?![[:alnum:]_]))/) &&
            (r1_0 = match(:unattributed)) &&
            @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>\{)/) &&
            (start_ws r1_0)
          end || begin
            @scanner.pos = p1
            false
          end
        end ||
        begin
          p1 = @scanner.pos
          begin
            @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>(?>%whitespace)(?![[:alnum:]_]))/) &&
            (r1_0 = match(:unattributed)) &&
            (set_ws r1_0)
          end || begin
            @scanner.pos = p1
            false
          end
        end ||
        begin
          p1 = @scanner.pos
          begin
            @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>(?>%word_character)(?![[:alnum:]_]))/) &&
            (r1_0 = match(:unattributed)) &&
            @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>\{)/) &&
            (start_wc r1_0)
          end || begin
            @scanner.pos = p1
            false
          end
        end ||
        begin
          p1 = @scanner.pos
          begin
            @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>(?>%word_character)(?![[:alnum:]_]))/) &&
            (r1_0 = match(:unattributed)) &&
            (set_wc r1_0)
          end || begin
            @scanner.pos = p1
            false
          end
        end ||
        begin
          @scanner.skip(/(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>(?>%inline)(?![[:alnum:]_])))(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>\{))/) &&
          (start_inline)
        end ||
        begin
          @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>(?>%inline)(?![[:alnum:]_]))/) &&
          (set_inline)
        end ||
        begin
          p1 = @scanner.pos
          begin
            @scanner.skip(/(?!(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>(?>EOF)(?![[:alnum:]_])))/) &&
            (r1_0 = begin
              @scanner.skip(/(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>[[:alpha:]])(?>(?>[[:alnum:]_])*)))(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?><\-))/) &&
              @scanner[1]
            end) &&
            (r1_1 = match(:expression)) &&
            (rule r1_0, r1_1)
          end || begin
            @scanner.pos = p1
            false
          end
        end ||
        begin
          @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>\})/) &&
          (end_block)
        end
      end
        a0 << r
      end
      RuleSet.parsed(select_captures(a0)) unless a0.empty?
    end) &&
    @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)\z/) &&
    Grammar.parsed([r0_0, r0_1])
  end || begin
    @scanner.pos = p0
    false
  end
end

#match_labelableObject



588
589
590
# File 'lib/rattler/grammar/metagrammar.rb', line 588

def match_labelable #:nodoc:
  memoize :match_labelable!
end

#match_labelable!Object



593
594
595
596
# File 'lib/rattler/grammar/metagrammar.rb', line 593

def match_labelable! #:nodoc:
  match(:list) ||
  match(:list_term)
end

#match_labeledObject



567
568
569
# File 'lib/rattler/grammar/metagrammar.rb', line 567

def match_labeled #:nodoc:
  memoize :match_labeled!
end

#match_labeled!Object



572
573
574
575
576
577
578
579
580
581
582
583
584
585
# File 'lib/rattler/grammar/metagrammar.rb', line 572

def match_labeled! #:nodoc:
  p0 = @scanner.pos
  begin
    (r0_0 = begin
      @scanner.skip(/(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>[[:lower:]])(?>(?>[[:alnum:]_])*)))(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>:))/) &&
      @scanner[1]
    end) &&
    (r0_1 = match(:labelable)) &&
    Label.parsed(select_captures([r0_0, r0_1]))
  end || begin
    @scanner.pos = p0
    false
  end
end

#match_listObject



599
600
601
# File 'lib/rattler/grammar/metagrammar.rb', line 599

def match_list #:nodoc:
  memoize :match_list!
end

#match_list!Object



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
# File 'lib/rattler/grammar/metagrammar.rb', line 604

def match_list! #:nodoc:
  begin
    p0 = @scanner.pos
    begin
      (r0_0 = match(:list_term)) &&
      @scanner.skip(/(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>\*))(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>,))/) &&
      (r0_1 = match(:list_term)) &&
      (list0 r0_0, r0_1)
    end || begin
      @scanner.pos = p0
      false
    end
  end ||
  begin
    p0 = @scanner.pos
    begin
      (r0_0 = match(:list_term)) &&
      @scanner.skip(/(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>\+))(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>,))/) &&
      (r0_1 = match(:list_term)) &&
      (list1 r0_0, r0_1)
    end || begin
      @scanner.pos = p0
      false
    end
  end ||
  begin
    p0 = @scanner.pos
    begin
      (r0_0 = match(:list_term)) &&
      (r0_1 = begin
        begin
          @scanner.skip(/(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>[[:digit:]])+))(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>\.\.))(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>[[:digit:]])+))/) &&
          ([@scanner[1], @scanner[2]].map {|s| s.to_i })
        end ||
        begin
          @scanner.skip(/(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>[[:digit:]])+))(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>\.\.))/) &&
          ([@scanner[1].to_i, nil])
        end ||
        begin
          @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>[[:digit:]])+)/) &&
          ([@scanner[1].to_i] * 2)
        end
      end) &&
      @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>,)/) &&
      (r0_2 = match(:list_term)) &&
      ListParser.parsed(select_captures([r0_0, r0_1, r0_2]))
    end || begin
      @scanner.pos = p0
      false
    end
  end
end

#match_list_termObject



658
659
660
# File 'lib/rattler/grammar/metagrammar.rb', line 658

def match_list_term #:nodoc:
  memoize :match_list_term!
end

#match_list_term!Object



663
664
665
666
667
# File 'lib/rattler/grammar/metagrammar.rb', line 663

def match_list_term! #:nodoc:
  match(:prefixed) ||
  match(:prefixable) ||
  (fail! { "term expected" })
end

#match_prefixableObject



723
724
725
# File 'lib/rattler/grammar/metagrammar.rb', line 723

def match_prefixable #:nodoc:
  memoize :match_prefixable!
end

#match_prefixable!Object



728
729
730
731
# File 'lib/rattler/grammar/metagrammar.rb', line 728

def match_prefixable! #:nodoc:
  match(:suffixed) ||
  match(:primary)
end

#match_prefixedObject



670
671
672
# File 'lib/rattler/grammar/metagrammar.rb', line 670

def match_prefixed #:nodoc:
  memoize :match_prefixed!
end

#match_prefixed!Object



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
# File 'lib/rattler/grammar/metagrammar.rb', line 675

def match_prefixed! #:nodoc:
  begin
    p0 = @scanner.pos
    begin
      @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>&)/) &&
      (r0_0 = match(:prefixable)) &&
      Assert.parsed(select_captures([r0_0]))
    end || begin
      @scanner.pos = p0
      false
    end
  end ||
  begin
    p0 = @scanner.pos
    begin
      @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>!)/) &&
      (r0_0 = match(:prefixable)) &&
      Disallow.parsed(select_captures([r0_0]))
    end || begin
      @scanner.pos = p0
      false
    end
  end ||
  begin
    p0 = @scanner.pos
    begin
      @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>~)/) &&
      (r0_0 = match(:prefixable)) &&
      Skip.parsed(select_captures([r0_0]))
    end || begin
      @scanner.pos = p0
      false
    end
  end ||
  begin
    p0 = @scanner.pos
    begin
      @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>@)/) &&
      (r0_0 = match(:prefixable)) &&
      Token.parsed(select_captures([r0_0]))
    end || begin
      @scanner.pos = p0
      false
    end
  end
end

#match_primaryObject



801
802
803
# File 'lib/rattler/grammar/metagrammar.rb', line 801

def match_primary #:nodoc:
  memoize :match_primary!
end

#match_primary!Object



806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
# File 'lib/rattler/grammar/metagrammar.rb', line 806

def match_primary! #:nodoc:
  begin
    p0 = @scanner.pos
    begin
      @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>\()/) &&
      (r0_0 = match(:expression)) &&
      @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>\))/) &&
      r0_0
    end || begin
      @scanner.pos = p0
      false
    end
  end ||
  begin
    @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>(?>EOF)(?![[:alnum:]_]))/) &&
    Eof.parsed([])
  end ||
  begin
    @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>(?>E)(?![[:alnum:]_]))/) &&
    ESymbol.parsed([])
  end ||
  begin
    (r = begin
      begin
        @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>ALNUM)(?![[:alnum:]_]))/) &&
        @scanner[1]
      end ||
      begin
        @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>ALPHA)(?![[:alnum:]_]))/) &&
        @scanner[1]
      end ||
      begin
        @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>ASCII)(?![[:alnum:]_]))/) &&
        @scanner[1]
      end ||
      begin
        @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>BLANK)(?![[:alnum:]_]))/) &&
        @scanner[1]
      end ||
      begin
        @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>CNTRL)(?![[:alnum:]_]))/) &&
        @scanner[1]
      end ||
      begin
        @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>DIGIT)(?![[:alnum:]_]))/) &&
        @scanner[1]
      end ||
      begin
        @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>GRAPH)(?![[:alnum:]_]))/) &&
        @scanner[1]
      end ||
      begin
        @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>LOWER)(?![[:alnum:]_]))/) &&
        @scanner[1]
      end ||
      begin
        @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>PRINT)(?![[:alnum:]_]))/) &&
        @scanner[1]
      end ||
      begin
        @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>PUNCT)(?![[:alnum:]_]))/) &&
        @scanner[1]
      end ||
      begin
        @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>SPACE)(?![[:alnum:]_]))/) &&
        @scanner[1]
      end ||
      begin
        @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>UPPER)(?![[:alnum:]_]))/) &&
        @scanner[1]
      end ||
      begin
        @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>XDIGIT)(?![[:alnum:]_]))/) &&
        @scanner[1]
      end ||
      begin
        @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>WORD)(?![[:alnum:]_]))/) &&
        @scanner[1]
      end ||
      (fail! { "posix_class expected" })
    end) && (posix_class r)
  end ||
  begin
    p0 = @scanner.pos
    begin
      @scanner.skip(/(?!(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>(?>EOF)(?![[:alnum:]_])))/) &&
      (r0_0 = begin
        @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>[[:alpha:]])(?>(?>[[:alnum:]_])*))/) &&
        @scanner[1]
      end) &&
      @scanner.skip(/(?!(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?><\-))/) &&
      Apply.parsed([r0_0])
    end || begin
      @scanner.pos = p0
      false
    end
  end ||
  begin
    (r = begin
      begin
        @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>")(?>(?>(?>\\)(?>.)|[^"])*)(?>"))/) &&
        @scanner[1]
      end ||
      begin
        @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>')(?>(?>(?>\\)(?>.)|[^'])*)(?>'))/) &&
        @scanner[1]
      end ||
      begin
        @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>%\()(?>(?>(?>\\)(?>.)|[^)])*)(?>\)))/) &&
        @scanner[1]
      end ||
      begin
        @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>%\{)(?>(?>(?>\\)(?>.)|[^}])*)(?>\}))/) &&
        @scanner[1]
      end ||
      begin
        @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>%\[)(?>(?>(?>\\)(?>.)|[^\]])*)(?>\]))/) &&
        @scanner[1]
      end ||
      begin
        @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>%<)(?>(?>(?>\\)(?>.)|[^>])*)(?>>))/) &&
        @scanner[1]
      end ||
      begin
        p0 = @scanner.pos
        begin
          @scanner.skip(/(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*/) &&
          begin
            p1 = @scanner.pos
            begin
              @scanner.skip(/%/) &&
              (r1_0 = @scanner.scan(/[[:punct:]]/)) &&
              begin
                while begin
                  @scanner.skip(/(?>\\)(?>.)/) ||
                  begin
                    p2 = @scanner.pos
                    begin
                      @scanner.skip(/(?!#{r1_0})/) &&
                      @scanner.skip(/./) &&
                      true
                    end || begin
                      @scanner.pos = p2
                      false
                    end
                  end
                end; end
                true
              end &&
              @scanner.skip(/#{r1_0}/) &&
              @scanner.string[p1...(@scanner.pos)]
            end || begin
              @scanner.pos = p1
              false
            end
          end
        end || begin
          @scanner.pos = p0
          false
        end
      end
    end) && (literal r)
  end ||
  begin
    @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>`)(?>(?>(?>\\)(?>.)|[^`])*)(?>`))/) &&
    (word_literal @scanner[1])
  end ||
  begin
    @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>\[)(?>(?>(?!\])(?>(?>\[:)(?>(?>alnum)(?![[:alnum:]_])|(?>alpha)(?![[:alnum:]_])|(?>ascii)(?![[:alnum:]_])|(?>blank)(?![[:alnum:]_])|(?>cntrl)(?![[:alnum:]_])|(?>digit)(?![[:alnum:]_])|(?>graph)(?![[:alnum:]_])|(?>lower)(?![[:alnum:]_])|(?>print)(?![[:alnum:]_])|(?>punct)(?![[:alnum:]_])|(?>space)(?![[:alnum:]_])|(?>upper)(?![[:alnum:]_])|(?>xdigit)(?![[:alnum:]_]))(?>:\])|(?>(?>\\)(?>[0-3])(?>[0-7])(?>[0-7])|(?>\\x)(?>[[:xdigit:]])(?>[[:xdigit:]])|(?>\\)(?>.)|[^\\\]])(?>(?>(?>\-)(?>(?>\\)(?>[0-3])(?>[0-7])(?>[0-7])|(?>\\x)(?>[[:xdigit:]])(?>[[:xdigit:]])|(?>\\)(?>.)|[^\\\]]))?)))+)(?>\]))/) &&
    (char_class @scanner[1])
  end ||
  begin
    @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>\$)(?>[[:lower:]])(?>(?>[[:alnum:]_])*))/) &&
    BackReference.parsed([@scanner[1]])
  end ||
  begin
    @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>\.)/) &&
    (Match[/./])
  end ||
  (fail! { "atom expected" })
end

#match_suffixedObject



734
735
736
# File 'lib/rattler/grammar/metagrammar.rb', line 734

def match_suffixed #:nodoc:
  memoize :match_suffixed!
end

#match_suffixed!Object



739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
# File 'lib/rattler/grammar/metagrammar.rb', line 739

def match_suffixed! #:nodoc:
  begin
    p0 = @scanner.pos
    begin
      (r0_0 = match(:primary)) &&
      @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>\?)/) &&
      (optional r0_0)
    end || begin
      @scanner.pos = p0
      false
    end
  end ||
  begin
    p0 = @scanner.pos
    begin
      (r0_0 = match(:primary)) &&
      @scanner.skip(/(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>\*))(?!(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>,))/) &&
      (zero_or_more r0_0)
    end || begin
      @scanner.pos = p0
      false
    end
  end ||
  begin
    p0 = @scanner.pos
    begin
      (r0_0 = match(:primary)) &&
      @scanner.skip(/(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>\+))(?!(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>,))/) &&
      (one_or_more r0_0)
    end || begin
      @scanner.pos = p0
      false
    end
  end ||
  begin
    p0 = @scanner.pos
    begin
      (r0_0 = match(:primary)) &&
      (r0_1 = begin
        begin
          @scanner.skip(/(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>[[:digit:]])+))(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>\.\.))(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>[[:digit:]])+))/) &&
          ([@scanner[1], @scanner[2]].map {|s| s.to_i })
        end ||
        begin
          @scanner.skip(/(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>[[:digit:]])+))(?>(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>\.\.))/) &&
          ([@scanner[1].to_i, nil])
        end ||
        begin
          @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>[[:digit:]])+)/) &&
          ([@scanner[1].to_i] * 2)
        end
      end) &&
      @scanner.skip(/(?!(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>,))/) &&
      Repeat.parsed(select_captures([r0_0, r0_1]))
    end || begin
      @scanner.pos = p0
      false
    end
  end
end

#match_termObject



394
395
396
# File 'lib/rattler/grammar/metagrammar.rb', line 394

def match_term #:nodoc:
  memoize :match_term!
end

#match_term!Object



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
# File 'lib/rattler/grammar/metagrammar.rb', line 399

def match_term! #:nodoc:
  begin
    p0 = @scanner.pos
    begin
      (r0_0 = begin
        begin
          @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>fail)(?![[:alnum:]_]))/) &&
          @scanner[1]
        end ||
        begin
          @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>fail_rule)(?![[:alnum:]_]))/) &&
          @scanner[1]
        end ||
        begin
          @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>fail_parse)(?![[:alnum:]_]))/) &&
          @scanner[1]
        end
      end) &&
      (r0_1 = begin
        begin
          p1 = @scanner.pos
          begin
            @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>\()/) &&
            (r1_0 = begin
              begin
                @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>")(?>(?>(?>\\)(?>.)|[^"])*)(?>"))/) &&
                @scanner[1]
              end ||
              begin
                @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>')(?>(?>(?>\\)(?>.)|[^'])*)(?>'))/) &&
                @scanner[1]
              end ||
              begin
                @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>%\()(?>(?>(?>\\)(?>.)|[^)])*)(?>\)))/) &&
                @scanner[1]
              end ||
              begin
                @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>%\{)(?>(?>(?>\\)(?>.)|[^}])*)(?>\}))/) &&
                @scanner[1]
              end ||
              begin
                @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>%\[)(?>(?>(?>\\)(?>.)|[^\]])*)(?>\]))/) &&
                @scanner[1]
              end ||
              begin
                @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>%<)(?>(?>(?>\\)(?>.)|[^>])*)(?>>))/) &&
                @scanner[1]
              end ||
              begin
                p2 = @scanner.pos
                begin
                  @scanner.skip(/(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*/) &&
                  begin
                    p3 = @scanner.pos
                    begin
                      @scanner.skip(/%/) &&
                      (r3_0 = @scanner.scan(/[[:punct:]]/)) &&
                      begin
                        while begin
                          @scanner.skip(/(?>\\)(?>.)/) ||
                          begin
                            p4 = @scanner.pos
                            begin
                              @scanner.skip(/(?!#{r3_0})/) &&
                              @scanner.skip(/./) &&
                              true
                            end || begin
                              @scanner.pos = p4
                              false
                            end
                          end
                        end; end
                        true
                      end &&
                      @scanner.skip(/#{r3_0}/) &&
                      @scanner.string[p3...(@scanner.pos)]
                    end || begin
                      @scanner.pos = p3
                      false
                    end
                  end
                end || begin
                  @scanner.pos = p2
                  false
                end
              end
            end) &&
            @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>\))/) &&
            r1_0
          end || begin
            @scanner.pos = p1
            false
          end
        end ||
        begin
          @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>")(?>(?>(?>\\)(?>.)|[^"])*)(?>"))/) &&
          @scanner[1]
        end ||
        begin
          @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>')(?>(?>(?>\\)(?>.)|[^'])*)(?>'))/) &&
          @scanner[1]
        end ||
        begin
          @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>%\()(?>(?>(?>\\)(?>.)|[^)])*)(?>\)))/) &&
          @scanner[1]
        end ||
        begin
          @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>%\{)(?>(?>(?>\\)(?>.)|[^}])*)(?>\}))/) &&
          @scanner[1]
        end ||
        begin
          @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>%\[)(?>(?>(?>\\)(?>.)|[^\]])*)(?>\]))/) &&
          @scanner[1]
        end ||
        begin
          @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)((?>%<)(?>(?>(?>\\)(?>.)|[^>])*)(?>>))/) &&
          @scanner[1]
        end ||
        begin
          p1 = @scanner.pos
          begin
            @scanner.skip(/(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*/) &&
            begin
              p2 = @scanner.pos
              begin
                @scanner.skip(/%/) &&
                (r2_0 = @scanner.scan(/[[:punct:]]/)) &&
                begin
                  while begin
                    @scanner.skip(/(?>\\)(?>.)/) ||
                    begin
                      p3 = @scanner.pos
                      begin
                        @scanner.skip(/(?!#{r2_0})/) &&
                        @scanner.skip(/./) &&
                        true
                      end || begin
                        @scanner.pos = p3
                        false
                      end
                    end
                  end; end
                  true
                end &&
                @scanner.skip(/#{r2_0}/) &&
                @scanner.string[p2...(@scanner.pos)]
              end || begin
                @scanner.pos = p2
                false
              end
            end
          end || begin
            @scanner.pos = p1
            false
          end
        end
      end) &&
      Fail.parsed([r0_0, r0_1])
    end || begin
      @scanner.pos = p0
      false
    end
  end ||
  match(:labeled) ||
  match(:labelable)
end

#match_termsObject



373
374
375
# File 'lib/rattler/grammar/metagrammar.rb', line 373

def match_terms #:nodoc:
  memoize_lr :match_terms!
end

#match_terms!Object



378
379
380
381
382
383
384
385
386
387
388
389
390
391
# File 'lib/rattler/grammar/metagrammar.rb', line 378

def match_terms! #:nodoc:
  begin
    p0 = @scanner.pos
    begin
      (r0_0 = match(:terms)) &&
      (r0_1 = match(:term)) &&
      Sequence.parsed(select_captures([r0_0, r0_1]))
    end || begin
      @scanner.pos = p0
      false
    end
  end ||
  match(:term)
end

#match_unattributedObject



162
163
164
# File 'lib/rattler/grammar/metagrammar.rb', line 162

def match_unattributed #:nodoc:
  memoize_lr :match_unattributed!
end

#match_unattributed!Object



167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/rattler/grammar/metagrammar.rb', line 167

def match_unattributed! #:nodoc:
  begin
    p0 = @scanner.pos
    begin
      (r0_0 = match(:unattributed)) &&
      @scanner.skip(/(?>(?>(?>[[:space:]])+|(?>\#)(?>(?>[^\n])*))*)(?>\/)/) &&
      (r0_1 = match(:terms)) &&
      Choice.parsed(select_captures([r0_0, r0_1]))
    end || begin
      @scanner.pos = p0
      false
    end
  end ||
  match(:terms)
end

#start_ruleObject



11
12
13
# File 'lib/rattler/grammar/metagrammar.rb', line 11

def start_rule #:nodoc:
  :grammar
end