Module: Fig::Grammar::Version

Includes:
Treetop::Runtime
Included in:
V0, V1, V2, VersionIdentification, VersionParser
Defined in:
lib/fig/grammar/version.rb

Defined Under Namespace

Modules: GrammarVersion0, GrammarVersion1

Instance Method Summary collapse

Instance Method Details

#_nt_grammar_versionObject



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
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
# File 'lib/fig/grammar/version.rb', line 41

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

  i0, s0 = index, []
  if (match_len = has_terminal?('grammar', false, index))
    r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
    @index += match_len
  else
    terminal_parse_failure('grammar')
    r1 = nil
  end
  s0 << r1
  if r1
    s2, i2 = [], index
    loop do
      r3 = _nt_ws_or_comment
      if r3
        s2 << r3
      else
        break
      end
    end
    if s2.empty?
      @index = i2
      r2 = nil
    else
      r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
    end
    s0 << r2
    if r2
      if (match_len = has_terminal?('v', false, index))
        r4 = true
        @index += match_len
      else
        terminal_parse_failure('v')
        r4 = nil
      end
      s0 << r4
      if r4
        s5, i5 = [], index
        loop do
          if has_terminal?(@regexps[gr = '\A[\\d]'] ||= Regexp.new(gr), :regexp, index)
            r6 = true
            @index += 1
          else
            terminal_parse_failure('[\\d]')
            r6 = nil
          end
          if r6
            s5 << r6
          else
            break
          end
        end
        if s5.empty?
          @index = i5
          r5 = nil
        else
          r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
        end
        s0 << r5
        if r5
          s7, i7 = [], index
          loop do
            r8 = _nt_ws
            if r8
              s7 << r8
            else
              break
            end
          end
          r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
          s0 << r7
        end
      end
    end
  end
  if s0.last
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
    r0.extend(GrammarVersion0)
    r0.extend(GrammarVersion1)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:grammar_version][start_index] = r0

  r0
end

#rootObject



18
19
20
# File 'lib/fig/grammar/version.rb', line 18

def root
  @root ||= :grammar_version
end