Module: Hemingway::Block::Quote

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

Defined Under Namespace

Modules: QuoteLastParagraph0, QuoteParagraph0

Instance Method Summary collapse

Instance Method Details

#_nt_quote_entryObject



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

def _nt_quote_entry
  start_index = index
  if node_cache[:quote_entry].has_key?(index)
    cached = node_cache[:quote_entry][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 = index
    r2 = _nt_quote_paragraph
    if r2
      r1 = r2
    else
      r3 = _nt_quote_last_paragraph
      if r3
        r1 = r3
      else
        @index = i1
        r1 = nil
      end
    end
    if r1
      s0 << r1
    else
      break
    end
  end
  r0 = instantiate_node(QuoteEntryNode,input, i0...index, s0)

  node_cache[:quote_entry][start_index] = r0

  r0
end

#_nt_quote_last_paragraphObject



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

def _nt_quote_last_paragraph
  start_index = index
  if node_cache[:quote_last_paragraph].has_key?(index)
    cached = node_cache[:quote_last_paragraph][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
    r2 = _nt_content
    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
    r4 = _nt_eop
    if r4
      r3 = r4
    else
      r3 = instantiate_node(SyntaxNode,input, index...index)
    end
    s0 << r3
  end
  if s0.last
    r0 = instantiate_node(QuoteParagraphNode,input, i0...index, s0)
    r0.extend(QuoteLastParagraph0)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:quote_last_paragraph][start_index] = r0

  r0
end

#_nt_quote_paragraphObject



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

def _nt_quote_paragraph
  start_index = index
  if node_cache[:quote_paragraph].has_key?(index)
    cached = node_cache[:quote_paragraph][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
    r2 = _nt_content
    if r2
      s1 << r2
    else
      break
    end
  end
  r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
  s0 << r1
  if r1
    r3 = _nt_eop
    s0 << r3
  end
  if s0.last
    r0 = instantiate_node(QuoteParagraphNode,input, i0...index, s0)
    r0.extend(QuoteParagraph0)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:quote_paragraph][start_index] = r0

  r0
end

#_nt_quote_typeObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/hemingway/block/quote/quote.rb', line 15

def _nt_quote_type
  start_index = index
  if node_cache[:quote_type].has_key?(index)
    cached = node_cache[:quote_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?("quote", false, index)
    r0 = instantiate_node(QuoteNode,input, index...(index + 5))
    @index += 5
  else
    terminal_parse_failure("quote")
    r0 = nil
  end

  node_cache[:quote_type][start_index] = r0

  r0
end

#rootObject



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

def root
  @root ||= :quote_type
end