Module: Hemingway::Block::Center

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

Defined Under Namespace

Modules: Center0, Center1

Instance Method Summary collapse

Instance Method Details

#_nt_centerObject



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

def _nt_center
  start_index = index
  if node_cache[:center].has_key?(index)
    cached = node_cache[:center][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
    i2, s2 = index, []
    i3 = index
    i4, s4 = index, []
    r5 = _nt_block_end
    s4 << r5
    if r5
      r6 = _nt_center_type
      s4 << r6
    end
    if s4.last
      r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
      r4.extend(Center0)
    else
      @index = i4
      r4 = nil
    end
    if r4
      r3 = nil
    else
      @index = i3
      r3 = instantiate_node(SyntaxNode,input, index...index)
    end
    s2 << r3
    if r3
      r7 = _nt_content
      s2 << r7
    end
    if s2.last
      r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
      r2.extend(Center1)
    else
      @index = i2
      r2 = nil
    end
    if r2
      r1 = r2
    else
      r8 = _nt_newline
      if r8
        r1 = r8
      else
        @index = i1
        r1 = nil
      end
    end
    if r1
      s0 << r1
    else
      break
    end
  end
  r0 = instantiate_node(SyntaxNode,input, i0...index, s0)

  node_cache[:center][start_index] = r0

  r0
end

#_nt_center_typeObject



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/hemingway/block/center/center.rb', line 103

def _nt_center_type
  start_index = index
  if node_cache[:center_type].has_key?(index)
    cached = node_cache[:center_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?("center", false, index)
    r0 = instantiate_node(CenterNode,input, index...(index + 6))
    @index += 6
  else
    terminal_parse_failure("center")
    r0 = nil
  end

  node_cache[:center_type][start_index] = r0

  r0
end

#rootObject



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

def root
  @root ||= :center
end