Module: Hemingway::Block::Verbatim

Includes:
Treetop::Runtime
Included in:
Hemingway::Block, VerbatimParser
Defined in:
lib/hemingway/block/verbatim/verbatim.rb

Defined Under Namespace

Modules: VerbatimText0, VerbatimText1

Instance Method Summary collapse

Instance Method Details

#_nt_verbatimObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/hemingway/block/verbatim/verbatim.rb', line 15

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

  r0 = _nt_verbatim_text

  node_cache[:verbatim][start_index] = r0

  r0
end

#_nt_verbatim_textObject



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
# File 'lib/hemingway/block/verbatim/verbatim.rb', line 71

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

  s0, i0 = [], index
  loop do
    i1, s1 = index, []
    i2 = index
    i3, s3 = index, []
    r4 = _nt_block_end
    s3 << r4
    if r4
      r5 = _nt_verbatim_type
      s3 << r5
      if r5
        if has_terminal?("}", false, index)
          r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
          @index += 1
        else
          terminal_parse_failure("}")
          r6 = nil
        end
        s3 << r6
      end
    end
    if s3.last
      r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
      r3.extend(VerbatimText0)
    else
      @index = i3
      r3 = nil
    end
    if r3
      r2 = nil
    else
      @index = i2
      r2 = instantiate_node(SyntaxNode,input, index...index)
    end
    s1 << r2
    if r2
      if index < input_length
        r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
        @index += 1
      else
        terminal_parse_failure("any character")
        r7 = nil
      end
      s1 << r7
    end
    if s1.last
      r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
      r1.extend(VerbatimText1)
    else
      @index = i1
      r1 = nil
    end
    if r1
      s0 << r1
    else
      break
    end
  end
  if s0.empty?
    @index = i0
    r0 = nil
  else
    r0 = instantiate_node(TextNode,input, i0...index, s0)
  end

  node_cache[:verbatim_text][start_index] = r0

  r0
end

#_nt_verbatim_typeObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/hemingway/block/verbatim/verbatim.rb', line 33

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

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

  node_cache[:verbatim_type][start_index] = r0

  r0
end

#rootObject



11
12
13
# File 'lib/hemingway/block/verbatim/verbatim.rb', line 11

def root
  @root ||= :verbatim
end