Module: Formatting

Includes:
Treetop::Runtime
Included in:
FormattingParser
Defined in:
lib/ntail/node.rb,
lib/ntail/formatting.rb

Defined Under Namespace

Modules: BodyBytesSent0, HttpReferer0, HttpUserAgent0, Literal0, ProxyAddresses0, RemoteAddr0, RemoteUser0, Request0, Status0, TimeLocal0 Classes: Node

Instance Method Summary collapse

Instance Method Details

#_nt_body_bytes_sentObject



318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
# File 'lib/ntail/formatting.rb', line 318

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

  if has_terminal?('%b', false, index)
    r0 = instantiate_node(Node,input, index...(index + 2))
    r0.extend(BodyBytesSent0)
    @index += 2
  else
    terminal_parse_failure('%b')
    r0 = nil
  end

  node_cache[:body_bytes_sent][start_index] = r0

  r0
end

#_nt_format_stringObject



11
12
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
51
52
53
# File 'lib/ntail/formatting.rb', line 11

def _nt_format_string
  start_index = index
  if node_cache[:format_string].has_key?(index)
    cached = node_cache[:format_string][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_token
    if r2
      r1 = r2
    else
      r3 = _nt_literal
      if r3
        r1 = r3
      else
        @index = i1
        r1 = nil
      end
    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[:format_string][start_index] = r0

  r0
end

#_nt_http_refererObject



349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
# File 'lib/ntail/formatting.rb', line 349

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

  if has_terminal?('%R', false, index)
    r0 = instantiate_node(Node,input, index...(index + 2))
    r0.extend(HttpReferer0)
    @index += 2
  else
    terminal_parse_failure('%R')
    r0 = nil
  end

  node_cache[:http_referer][start_index] = r0

  r0
end

#_nt_http_user_agentObject



380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
# File 'lib/ntail/formatting.rb', line 380

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

  if has_terminal?('%U', false, index)
    r0 = instantiate_node(Node,input, index...(index + 2))
    r0.extend(HttpUserAgent0)
    @index += 2
  else
    terminal_parse_failure('%U')
    r0 = nil
  end

  node_cache[:http_user_agent][start_index] = r0

  r0
end

#_nt_literalObject



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/ntail/formatting.rb', line 62

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

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

  node_cache[:literal][start_index] = r0

  r0
end

#_nt_proxy_addressesObject



411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
# File 'lib/ntail/formatting.rb', line 411

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

  if has_terminal?('%p', false, index)
    r0 = instantiate_node(Node,input, index...(index + 2))
    r0.extend(ProxyAddresses0)
    @index += 2
  else
    terminal_parse_failure('%p')
    r0 = nil
  end

  node_cache[:proxy_addresses][start_index] = r0

  r0
end

#_nt_remote_addrObject



163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# File 'lib/ntail/formatting.rb', line 163

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

  if has_terminal?('%a', false, index)
    r0 = instantiate_node(Node,input, index...(index + 2))
    r0.extend(RemoteAddr0)
    @index += 2
  else
    terminal_parse_failure('%a')
    r0 = nil
  end

  node_cache[:remote_addr][start_index] = r0

  r0
end

#_nt_remote_userObject



194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# File 'lib/ntail/formatting.rb', line 194

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

  if has_terminal?('%u', false, index)
    r0 = instantiate_node(Node,input, index...(index + 2))
    r0.extend(RemoteUser0)
    @index += 2
  else
    terminal_parse_failure('%u')
    r0 = nil
  end

  node_cache[:remote_user][start_index] = r0

  r0
end

#_nt_requestObject



256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
# File 'lib/ntail/formatting.rb', line 256

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

  if has_terminal?('%r', false, index)
    r0 = instantiate_node(Node,input, index...(index + 2))
    r0.extend(Request0)
    @index += 2
  else
    terminal_parse_failure('%r')
    r0 = nil
  end

  node_cache[:request][start_index] = r0

  r0
end

#_nt_statusObject



287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
# File 'lib/ntail/formatting.rb', line 287

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

  if has_terminal?('%s', false, index)
    r0 = instantiate_node(Node,input, index...(index + 2))
    r0.extend(Status0)
    @index += 2
  else
    terminal_parse_failure('%s')
    r0 = nil
  end

  node_cache[:status][start_index] = r0

  r0
end

#_nt_time_localObject



225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# File 'lib/ntail/formatting.rb', line 225

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

  if has_terminal?('%t', false, index)
    r0 = instantiate_node(Node,input, index...(index + 2))
    r0.extend(TimeLocal0)
    @index += 2
  else
    terminal_parse_failure('%t')
    r0 = nil
  end

  node_cache[:time_local][start_index] = r0

  r0
end

#_nt_tokenObject



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
143
144
145
146
147
148
149
150
# File 'lib/ntail/formatting.rb', line 87

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

  i0 = index
  r1 = _nt_remote_addr
  if r1
    r0 = r1
  else
    r2 = _nt_remote_user
    if r2
      r0 = r2
    else
      r3 = _nt_time_local
      if r3
        r0 = r3
      else
        r4 = _nt_request
        if r4
          r0 = r4
        else
          r5 = _nt_status
          if r5
            r0 = r5
          else
            r6 = _nt_body_bytes_sent
            if r6
              r0 = r6
            else
              r7 = _nt_http_referer
              if r7
                r0 = r7
              else
                r8 = _nt_http_user_agent
                if r8
                  r0 = r8
                else
                  r9 = _nt_proxy_addresses
                  if r9
                    r0 = r9
                  else
                    @index = i0
                    r0 = nil
                  end
                end
              end
            end
          end
        end
      end
    end
  end

  node_cache[:token][start_index] = r0

  r0
end

#rootObject



7
8
9
# File 'lib/ntail/formatting.rb', line 7

def root
  @root ||= :format_string
end