Module: TreetopTestGrammar

Includes:
Treetop::Runtime
Included in:
TreetopTestGrammarParser
Defined in:
lib/appswarm/tools/treetop_test_grammar.rb

Defined Under Namespace

Modules: BasicString0, BasicString1

Instance Method Summary collapse

Instance Method Details

#_nt_BasicStringObject



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
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
102
103
104
105
106
107
# File 'lib/appswarm/tools/treetop_test_grammar.rb', line 14

def _nt_BasicString
  start_index = index
  if node_cache[:BasicString].has_key?(index)
    cached = node_cache[:BasicString][index]
    @index = cached.interval.end if cached
    return cached
  end

  i0, s0 = index, []
  if input.index('"', index) == index
    r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
    @index += 1
  else
    terminal_parse_failure('"')
    r1 = nil
  end
  s0 << r1
  if r1
    s2, i2 = [], index
    loop do
      i3 = index
      i4, s4 = index, []
      if input.index('\\', index) == index
        r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
        @index += 1
      else
        terminal_parse_failure('\\')
        r5 = nil
      end
      s4 << r5
      if r5
        if index < input_length
          r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
          @index += 1
        else
          terminal_parse_failure("any character")
          r6 = nil
        end
        s4 << r6
      end
      if s4.last
        r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
        r4.extend(BasicString0)
      else
        self.index = i4
        r4 = nil
      end
      if r4
        r3 = r4
      else
        if input.index(Regexp.new('[^"\\\\]'), index) == index
          r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
          @index += 1
        else
          r7 = nil
        end
        if r7
          r3 = r7
        else
          self.index = i3
          r3 = nil
        end
      end
      if r3
        s2 << r3
      else
        break
      end
    end
    r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
    s0 << r2
    if r2
      if input.index('"', index) == index
        r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
        @index += 1
      else
        terminal_parse_failure('"')
        r8 = nil
      end
      s0 << r8
    end
  end
  if s0.last
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
    r0.extend(BasicString1)
  else
    self.index = i0
    r0 = nil
  end

  node_cache[:BasicString][start_index] = r0

  return r0
end

#rootObject



4
5
6
# File 'lib/appswarm/tools/treetop_test_grammar.rb', line 4

def root
  @root || :BasicString
end