Module: Hemingway::Tag

Includes:
Treetop::Runtime
Included in:
Latex, TagParser
Defined in:
lib/hemingway/tag/tag.rb

Defined Under Namespace

Modules: Tag0, Tag1, Tag2, Tag3, Tag4, Tag5, VerticalHeight0

Instance Method Summary collapse

Instance Method Details

#_nt_accentObject



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
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
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
# File 'lib/hemingway/tag/tag.rb', line 547

def _nt_accent
  start_index = index
  if node_cache[:accent].has_key?(index)
    cached = node_cache[:accent][index]
    if cached
      cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  i0 = index
  if has_terminal?('`', false, index)
    r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
    @index += 1
  else
    terminal_parse_failure('`')
    r1 = nil
  end
  if r1
    r0 = r1
  else
    if has_terminal?("'", false, index)
      r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
      @index += 1
    else
      terminal_parse_failure("'")
      r2 = nil
    end
    if r2
      r0 = r2
    else
      if has_terminal?('^', false, index)
        r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
        @index += 1
      else
        terminal_parse_failure('^')
        r3 = nil
      end
      if r3
        r0 = r3
      else
        if has_terminal?('"', false, index)
          r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
          @index += 1
        else
          terminal_parse_failure('"')
          r4 = nil
        end
        if r4
          r0 = r4
        else
          if has_terminal?("c", false, index)
            r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
            @index += 1
          else
            terminal_parse_failure("c")
            r5 = nil
          end
          if r5
            r0 = r5
          else
            if has_terminal?("~", false, index)
              r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
              @index += 1
            else
              terminal_parse_failure("~")
              r6 = nil
            end
            if r6
              r0 = r6
            else
              if has_terminal?("r", false, index)
                r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
                @index += 1
              else
                terminal_parse_failure("r")
                r7 = nil
              end
              if r7
                r0 = r7
              else
                @index = i0
                r0 = nil
              end
            end
          end
        end
      end
    end
  end

  node_cache[:accent][start_index] = r0

  r0
end

#_nt_hfillObject



499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
# File 'lib/hemingway/tag/tag.rb', line 499

def _nt_hfill
  start_index = index
  if node_cache[:hfill].has_key?(index)
    cached = node_cache[:hfill][index]
    if cached
      cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  if has_terminal?("hfill", false, index)
    r0 = instantiate_node(SyntaxNode,input, index...(index + 5))
    @index += 5
  else
    terminal_parse_failure("hfill")
    r0 = nil
  end

  node_cache[:hfill][start_index] = r0

  r0
end

#_nt_millimeterObject



475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
# File 'lib/hemingway/tag/tag.rb', line 475

def _nt_millimeter
  start_index = index
  if node_cache[:millimeter].has_key?(index)
    cached = node_cache[:millimeter][index]
    if cached
      cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  if has_terminal?("mm", false, index)
    r0 = instantiate_node(SyntaxNode,input, index...(index + 2))
    @index += 2
  else
    terminal_parse_failure("mm")
    r0 = nil
  end

  node_cache[:millimeter][start_index] = r0

  r0
end

#_nt_neatlineObject



523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
# File 'lib/hemingway/tag/tag.rb', line 523

def _nt_neatline
  start_index = index
  if node_cache[:neatline].has_key?(index)
    cached = node_cache[:neatline][index]
    if cached
      cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  if has_terminal?("neatline", false, index)
    r0 = instantiate_node(SyntaxNode,input, index...(index + 8))
    @index += 8
  else
    terminal_parse_failure("neatline")
    r0 = nil
  end

  node_cache[:neatline][start_index] = r0

  r0
end

#_nt_tagObject



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
# File 'lib/hemingway/tag/tag.rb', line 93

def _nt_tag
  start_index = index
  if node_cache[:tag].has_key?(index)
    cached = node_cache[:tag][index]
    if cached
      cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  i0 = index
  i1, s1 = index, []
  r2 = _nt_tag_start
  s1 << r2
  if r2
    r3 = _nt_tag_type
    s1 << r3
    if r3
      if has_terminal?("{", false, index)
        r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
        @index += 1
      else
        terminal_parse_failure("{")
        r4 = nil
      end
      s1 << r4
      if r4
        s5, i5 = [], index
        loop do
          r6 = _nt_content
          if r6
            s5 << r6
          else
            break
          end
        end
        r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
        s1 << r5
        if r5
          if has_terminal?("}", false, index)
            r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
            @index += 1
          else
            terminal_parse_failure("}")
            r7 = nil
          end
          s1 << r7
        end
      end
    end
  end
  if s1.last
    r1 = instantiate_node(TagNode,input, i1...index, s1)
    r1.extend(Tag0)
  else
    @index = i1
    r1 = nil
  end
  if r1
    r0 = r1
  else
    i8, s8 = index, []
    r9 = _nt_tag_start
    s8 << r9
    if r9
      r10 = _nt_vertical_space
      s8 << r10
      if r10
        if has_terminal?("{", false, index)
          r11 = instantiate_node(SyntaxNode,input, index...(index + 1))
          @index += 1
        else
          terminal_parse_failure("{")
          r11 = nil
        end
        s8 << r11
        if r11
          r12 = _nt_vertical_height
          s8 << r12
          if r12
            if has_terminal?("}", false, index)
              r13 = instantiate_node(SyntaxNode,input, index...(index + 1))
              @index += 1
            else
              terminal_parse_failure("}")
              r13 = nil
            end
            s8 << r13
          end
        end
      end
    end
    if s8.last
      r8 = instantiate_node(VerticalSpaceTagNode,input, i8...index, s8)
      r8.extend(Tag1)
    else
      @index = i8
      r8 = nil
    end
    if r8
      r0 = r8
    else
      i14, s14 = index, []
      r15 = _nt_tag_start
      s14 << r15
      if r15
        r16 = _nt_hfill
        s14 << r16
        if r16
          r17 = _nt_spaces
          s14 << r17
          if r17
            s18, i18 = [], index
            loop do
              i19, s19 = index, []
              i20 = index
              r21 = _nt_newline
              if r21
                r20 = nil
              else
                @index = i20
                r20 = instantiate_node(SyntaxNode,input, index...index)
              end
              s19 << r20
              if r20
                r22 = _nt_content
                s19 << r22
              end
              if s19.last
                r19 = instantiate_node(SyntaxNode,input, i19...index, s19)
                r19.extend(Tag2)
              else
                @index = i19
                r19 = nil
              end
              if r19
                s18 << r19
              else
                break
              end
            end
            r18 = instantiate_node(SyntaxNode,input, i18...index, s18)
            s14 << r18
          end
        end
      end
      if s14.last
        r14 = instantiate_node(HFillNode,input, i14...index, s14)
        r14.extend(Tag3)
      else
        @index = i14
        r14 = nil
      end
      if r14
        r0 = r14
      else
        i23, s23 = index, []
        r24 = _nt_tag_start
        s23 << r24
        if r24
          r25 = _nt_neatline
          s23 << r25
        end
        if s23.last
          r23 = instantiate_node(NeatLineNode,input, i23...index, s23)
          r23.extend(Tag4)
        else
          @index = i23
          r23 = nil
        end
        if r23
          r0 = r23
        else
          i26, s26 = index, []
          r27 = _nt_tag_start
          s26 << r27
          if r27
            r28 = _nt_accent
            s26 << r28
            if r28
              if has_terminal?("{", false, index)
                r29 = instantiate_node(SyntaxNode,input, index...(index + 1))
                @index += 1
              else
                terminal_parse_failure("{")
                r29 = nil
              end
              s26 << r29
              if r29
                if index < input_length
                  r30 = instantiate_node(SyntaxNode,input, index...(index + 1))
                  @index += 1
                else
                  terminal_parse_failure("any character")
                  r30 = nil
                end
                s26 << r30
                if r30
                  if has_terminal?("}", false, index)
                    r31 = instantiate_node(SyntaxNode,input, index...(index + 1))
                    @index += 1
                  else
                    terminal_parse_failure("}")
                    r31 = nil
                  end
                  s26 << r31
                end
              end
            end
          end
          if s26.last
            r26 = instantiate_node(AccentNode,input, i26...index, s26)
            r26.extend(Tag5)
          else
            @index = i26
            r26 = nil
          end
          if r26
            r0 = r26
          else
            @index = i0
            r0 = nil
          end
        end
      end
    end
  end

  node_cache[:tag][start_index] = r0

  r0
end

#_nt_tag_endObject



668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
# File 'lib/hemingway/tag/tag.rb', line 668

def _nt_tag_end
  start_index = index
  if node_cache[:tag_end].has_key?(index)
    cached = node_cache[:tag_end][index]
    if cached
      cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  if has_terminal?("}", false, index)
    r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
    @index += 1
  else
    terminal_parse_failure("}")
    r0 = nil
  end

  node_cache[:tag_end][start_index] = r0

  r0
end

#_nt_tag_startObject



644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
# File 'lib/hemingway/tag/tag.rb', line 644

def _nt_tag_start
  start_index = index
  if node_cache[:tag_start].has_key?(index)
    cached = node_cache[:tag_start][index]
    if cached
      cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  if has_terminal?("\\", false, index)
    r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
    @index += 1
  else
    terminal_parse_failure("\\")
    r0 = nil
  end

  node_cache[:tag_start][start_index] = r0

  r0
end

#_nt_tag_typeObject



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
# File 'lib/hemingway/tag/tag.rb', line 327

def _nt_tag_type
  start_index = index
  if node_cache[:tag_type].has_key?(index)
    cached = node_cache[:tag_type][index]
    if cached
      cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  i0 = index
  if has_terminal?("emph", false, index)
    r1 = instantiate_node(EmphTagNode,input, index...(index + 4))
    @index += 4
  else
    terminal_parse_failure("emph")
    r1 = nil
  end
  if r1
    r0 = r1
  else
    if has_terminal?("texttt", false, index)
      r2 = instantiate_node(TextttTagNode,input, index...(index + 6))
      @index += 6
    else
      terminal_parse_failure("texttt")
      r2 = nil
    end
    if r2
      r0 = r2
    else
      if has_terminal?("textbf", false, index)
        r3 = instantiate_node(TextbfTagNode,input, index...(index + 6))
        @index += 6
      else
        terminal_parse_failure("textbf")
        r3 = nil
      end
      if r3
        r0 = r3
      else
        if has_terminal?("textsc", false, index)
          r4 = instantiate_node(TextscTagNode,input, index...(index + 6))
          @index += 6
        else
          terminal_parse_failure("textsc")
          r4 = nil
        end
        if r4
          r0 = r4
        else
          @index = i0
          r0 = nil
        end
      end
    end
  end

  node_cache[:tag_type][start_index] = r0

  r0
end

#_nt_vertical_heightObject



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
# File 'lib/hemingway/tag/tag.rb', line 425

def _nt_vertical_height
  start_index = index
  if node_cache[:vertical_height].has_key?(index)
    cached = node_cache[:vertical_height][index]
    if cached
      cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  i0, s0 = index, []
  s1, i1 = [], index
  loop do
    if has_terminal?('\G[0-9]', true, index)
      r2 = true
      @index += 1
    else
      r2 = nil
    end
    if r2
      s1 << r2
    else
      break
    end
  end
  if s1.empty?
    @index = i1
    r1 = nil
  else
    r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
  end
  s0 << r1
  if r1
    r3 = _nt_millimeter
    s0 << r3
  end
  if s0.last
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
    r0.extend(VerticalHeight0)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:vertical_height][start_index] = r0

  r0
end

#_nt_vertical_spaceObject



391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
# File 'lib/hemingway/tag/tag.rb', line 391

def _nt_vertical_space
  start_index = index
  if node_cache[:vertical_space].has_key?(index)
    cached = node_cache[:vertical_space][index]
    if cached
      cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  if has_terminal?("vspace", false, index)
    r0 = instantiate_node(SyntaxNode,input, index...(index + 6))
    @index += 6
  else
    terminal_parse_failure("vspace")
    r0 = nil
  end

  node_cache[:vertical_space][start_index] = r0

  r0
end

#rootObject



10
11
12
# File 'lib/hemingway/tag/tag.rb', line 10

def root
  @root ||= :tag
end