Module: Hemingway::Override

Includes:
Treetop::Runtime
Included in:
Latex, OverrideParser
Defined in:
lib/hemingway/override/override.rb

Instance Method Summary collapse

Instance Method Details

#_nt_overrideObject



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

def _nt_override
  start_index = index
  if node_cache[:override].has_key?(index)
    cached = node_cache[:override][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(MDashNode,input, index...(index + 3))
    @index += 3
  else
    terminal_parse_failure("---")
    r1 = nil
  end
  if r1
    r0 = r1
  else
    if has_terminal?("``", false, index)
      r2 = instantiate_node(LeftQuoteNode,input, index...(index + 2))
      @index += 2
    else
      terminal_parse_failure("``")
      r2 = nil
    end
    if r2
      r0 = r2
    else
      if has_terminal?("''", false, index)
        r3 = instantiate_node(RightQuoteNode,input, index...(index + 2))
        @index += 2
      else
        terminal_parse_failure("''")
        r3 = nil
      end
      if r3
        r0 = r3
      else
        @index = i0
        r0 = nil
      end
    end
  end

  node_cache[:override][start_index] = r0

  r0
end

#rootObject



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

def root
  @root ||= :override
end