Method: CEML::Lexer#_nt_comment

Defined in:
lib/ceml/lang/tt/lexer.rb

#_nt_commentObject



295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
# File 'lib/ceml/lang/tt/lexer.rb', line 295

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

  i0, s0 = index, []
  if has_terminal?('//', false, index)
    r1 = instantiate_node(SyntaxNode,input, index...(index + 2))
    @index += 2
  else
    terminal_parse_failure('//')
    r1 = nil
  end
  s0 << r1
  if r1
    r2 = _nt_text
    s0 << r2
  end
  if s0.last
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
    r0.extend(Comment0)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:comment][start_index] = r0

  r0
end