class AdLint::Cpp::InDefineDirective
Public Class Methods
new(lexer)
click to toggle source
Calls superclass method
AdLint::Cpp::LexerState::new
# File lib/adlint/cpp/lexer.rb, line 674 def initialize(lexer) super @tokens = [] end
Public Instance Methods
next_token()
click to toggle source
# File lib/adlint/cpp/lexer.rb, line 679 def next_token if @tokens.empty? tokenize_macro_name(@lexer.content) tokenize_pp_tokens(@lexer.content) end tok = @tokens.shift @lexer.transit(Initial.new(@lexer)) if @tokens.empty? tok end
Private Instance Methods
tokenize_macro_name(cont)
click to toggle source
# File lib/adlint/cpp/lexer.rb, line 691 def tokenize_macro_name(cont) until cont.empty? next if discard_heading_comments || scan_escaped_newline(cont) if tok = tokenize_identifier(cont) @tokens.push(tok) break else cont.eat! end end return unless cont.check(/\(/) paren_depth = 0 until cont.empty? next if discard_heading_comments || scan_escaped_newline(cont) if tok = tokenize_identifier(cont) @tokens.push(tok) next end if tok = tokenize_punctuator(cont) @tokens.push(tok) case tok.type when "(" paren_depth += 1 when ")" paren_depth -= 1 break if paren_depth == 0 end next end if tok = tokenize_new_line(cont) @tokens.push(tok) break end cont.eat! end end
tokenize_pp_tokens(cont)
click to toggle source
# File lib/adlint/cpp/lexer.rb, line 735 def tokenize_pp_tokens(cont) until cont.empty? next if discard_heading_comments || scan_escaped_newline(cont) tok = tokenize_pp_token(cont) || tokenize_new_line(cont) if tok @tokens.push(tok) if tok.type == :NEW_LINE break end else loc = cont.location if eaten = cont.eat! and eaten !~ /\A\s\z/ @lexer.notify_unlexable_char_found(eaten, loc) end end end unless @tokens.last && @tokens.last.type == :NEW_LINE tok = Token.new(:NEW_LINE, "\n", cont.location) @lexer.notify_eof_newline_not_found(tok.location) @tokens.push(tok) end end