Class: AdLint::Cpp::Initial

Inherits:
LexerState show all
Defined in:
lib/adlint/cpp/lexer.rb

Instance Method Summary collapse

Methods inherited from LexerState

#initialize

Constructor Details

This class inherits a constructor from AdLint::Cpp::LexerState

Instance Method Details

#next_tokenObject



307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
# File 'lib/adlint/cpp/lexer.rb', line 307

def next_token
  # NOTE: An escaped newline may appear at the line above a preprocessing
  #       directive line.
  loop do
    unless discard_heading_comments || scan_escaped_newline(@lexer.content)
      break
    end
  end

  case
  when @lexer.content.check(/[ \t]*#/)
    case
    when tok = tokenize_if_directive(@lexer.content)
      @lexer.transit(InIfDirective.new(@lexer))
    when tok = tokenize_ifdef_directive(@lexer.content)
      @lexer.transit(InIfdefDirective.new(@lexer))
    when tok = tokenize_ifndef_directive(@lexer.content)
      @lexer.transit(InIfndefDirective.new(@lexer))
    when tok = tokenize_elif_directive(@lexer.content)
      @lexer.transit(InElifDirective.new(@lexer))
    when tok = tokenize_else_directive(@lexer.content)
      @lexer.transit(InElseDirective.new(@lexer))
    when tok = tokenize_endif_directive(@lexer.content)
      @lexer.transit(InEndifDirective.new(@lexer))
    when tok = tokenize_include_directive(@lexer.content)
      @lexer.transit(InIncludeDirective.new(@lexer))
    when tok = tokenize_include_next_directive(@lexer.content)
      @lexer.transit(InIncludeNextDirective.new(@lexer))
    when tok = tokenize_define_directive(@lexer.content)
      @lexer.transit(InDefineDirective.new(@lexer))
    when tok = tokenize_undef_directive(@lexer.content)
      @lexer.transit(InUndefDirective.new(@lexer))
    when tok = tokenize_line_directive(@lexer.content)
      @lexer.transit(InLineDirective.new(@lexer))
    when tok = tokenize_error_directive(@lexer.content)
      @lexer.transit(InErrorDirective.new(@lexer))
    when tok = tokenize_pragma_directive(@lexer.content)
      @lexer.transit(InPragmaDirective.new(@lexer))
    when tok = tokenize_asm_directive(@lexer.content)
      @lexer.transit(InAsmDirective.new(@lexer))
    when tok = tokenize_endasm_directive(@lexer.content)
      @lexer.transit(InEndasmDirective.new(@lexer))
    else
      tok = tokenize_null_directive(@lexer.content) ||
            tokenize_unknown_directive(@lexer.content)
    end
  else
    tok = tokenize_text_line(@lexer.content)
  end

  tok
end