Module: Brevity::Command

Includes:
Treetop::Runtime
Included in:
CommandParser, File
Defined in:
lib/brevity/parsing/file/command.rb

Defined Under Namespace

Modules: BracedArg0, BracedArg1, Command0

Instance Method Summary collapse

Instance Method Details

#_nt_braced_argObject



121
122
123
124
125
126
127
128
129
130
131
132
133
134
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'lib/brevity/parsing/file/command.rb', line 121

def _nt_braced_arg
  start_index = index
  if node_cache[:braced_arg].has_key?(index)
    cached = node_cache[:braced_arg][index]
    if cached
      node_cache[:braced_arg][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?("{", false, index))
    r1 = true
    @index += match_len
  else
    terminal_parse_failure("{")
    r1 = nil
  end
  s0 << r1
  if r1
    s2, i2 = [], index
    loop do
      i3, s3 = index, []
      i4 = index
      if (match_len = has_terminal?("}", false, index))
        r5 = true
        @index += match_len
      else
        terminal_parse_failure("}")
        r5 = nil
      end
      if r5
        r4 = nil
      else
        @index = i4
        r4 = instantiate_node(SyntaxNode,input, index...index)
      end
      s3 << r4
      if r4
        if index < input_length
          r6 = true
          @index += 1
        else
          terminal_parse_failure("any character")
          r6 = nil
        end
        s3 << r6
      end
      if s3.last
        r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
        r3.extend(BracedArg0)
      else
        @index = i3
        r3 = nil
      end
      if r3
        s2 << r3
      else
        break
      end
    end
    r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
    s0 << r2
    if r2
      if (match_len = has_terminal?("}", false, index))
        r7 = true
        @index += match_len
      else
        terminal_parse_failure("}")
        r7 = nil
      end
      s0 << r7
    end
  end
  if s0.last
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
    r0.extend(BracedArg1)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:braced_arg][start_index] = r0

  r0
end

#_nt_cmd_nameObject



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
# File 'lib/brevity/parsing/file/command.rb', line 73

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

  s0, i0 = [], index
  loop do
    if has_terminal?(@regexps[gr = '\A[a-z]'] ||= Regexp.new(gr), :regexp, index)
      r1 = true
      @index += 1
    else
      terminal_parse_failure('[a-z]')
      r1 = nil
    end
    if r1
      s0 << r1
    else
      break
    end
  end
  if s0.empty?
    @index = i0
    r0 = nil
  else
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
  end

  node_cache[:cmd_name][start_index] = r0

  r0
end

#_nt_commandObject



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
# File 'lib/brevity/parsing/file/command.rb', line 23

def _nt_command
  start_index = index
  if node_cache[:command].has_key?(index)
    cached = node_cache[:command][index]
    if cached
      node_cache[:command][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?("\\", false, index))
    r1 = true
    @index += match_len
  else
    terminal_parse_failure("\\")
    r1 = nil
  end
  s0 << r1
  if r1
    r2 = _nt_cmd_name
    s0 << r2
    if r2
      s3, i3 = [], index
      loop do
        r4 = _nt_braced_arg
        if r4
          s3 << r4
        else
          break
        end
      end
      r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
      s0 << r3
    end
  end
  if s0.last
    r0 = instantiate_node(CommandNode,input, i0...index, s0)
    r0.extend(Command0)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:command][start_index] = r0

  r0
end

#rootObject



9
10
11
# File 'lib/brevity/parsing/file/command.rb', line 9

def root
  @root ||= :command
end