Module: Cucumber::Parser::Common

Includes:
Treetop::Runtime
Included in:
CommonParser, PyString, Table
Defined in:
lib/cucumber/parser/common.rb

Defined Under Namespace

Modules: Eol0

Instance Method Summary collapse

Instance Method Details

#_nt_eofObject



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
# File 'lib/cucumber/parser/common.rb', line 144

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

  i0 = index
  if index < input_length
    r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
    @index += 1
  else
    terminal_parse_failure("any character")
    r1 = nil
  end
  if r1
    r0 = nil
  else
    @index = i0
    r0 = instantiate_node(SyntaxNode,input, index...index)
  end

  node_cache[:eof][start_index] = r0

  r0
end

#_nt_eolObject



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
# File 'lib/cucumber/parser/common.rb', line 78

def _nt_eol
  start_index = index
  if node_cache[:eol].has_key?(index)
    cached = node_cache[:eol][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?("\n", false, index)
    r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
    @index += 1
  else
    terminal_parse_failure("\n")
    r1 = nil
  end
  if r1
    r0 = r1
  else
    i2, s2 = index, []
    if has_terminal?("\r", false, index)
      r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
      @index += 1
    else
      terminal_parse_failure("\r")
      r3 = nil
    end
    s2 << r3
    if r3
      if has_terminal?("\n", false, index)
        r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
        @index += 1
      else
        terminal_parse_failure("\n")
        r5 = nil
      end
      if r5
        r4 = r5
      else
        r4 = instantiate_node(SyntaxNode,input, index...index)
      end
      s2 << r4
    end
    if s2.last
      r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
      r2.extend(Eol0)
    else
      @index = i2
      r2 = nil
    end
    if r2
      r0 = r2
    else
      @index = i0
      r0 = nil
    end
  end

  node_cache[:eol][start_index] = r0

  r0
end

#_nt_spaceObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/cucumber/parser/common.rb', line 52

def _nt_space
  start_index = index
  if node_cache[:space].has_key?(index)
    cached = node_cache[: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?('\G[ \\t]', true, index)
    r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
    @index += 1
  else
    r0 = nil
  end

  node_cache[:space][start_index] = r0

  r0
end

#_nt_whiteObject



13
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
# File 'lib/cucumber/parser/common.rb', line 13

def _nt_white
  start_index = index
  if node_cache[:white].has_key?(index)
    cached = node_cache[:white][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_space
    if r2
      r1 = r2
    else
      r3 = _nt_eol
      if r3
        r1 = r3
      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[:white][start_index] = r0

  r0
end

#rootObject



9
10
11
# File 'lib/cucumber/parser/common.rb', line 9

def root
  @root || :white
end