Class: CTokenizer::CPLexer
Overview
C Preprocessor Lexer
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from LexerBase
#empty?, #file, #initialize, #line, #peek_nonspace
Methods included from CTokenizer
check_string, check_token, #collect, create_newlines, #each, error, #error, join, line_count, #parse_error, split, split_token, #to_a, #token_error, #warning, whitespace?
Constructor Details
This class inherits a constructor from CTokenizer::LexerBase
Class Method Details
.convert_token(t) ⇒ Object
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 |
# File 'lib/dbc/ctokenizer.rb', line 375 def CPLexer.convert_token(t) case t[0] when :SYMBOL case t[1] when '!', '*', '/', '%', '+', '-', \ '<<', '>>', '(', ')', \ '<', '<=', '>', '>=', '==', '!=', \ '&', '^', '|', '&&', '||', \ '?', ':', '#', '##', '...', ',' t = [t[1], t[1]].freeze end # case when :IDENTIFIER if CPLexer.reserved_word?(t[1]) t = [t[1], t[1]].freeze end end # case t end |
.reserved_word?(str) ⇒ Boolean
371 372 373 |
# File 'lib/dbc/ctokenizer.rb', line 371 def CPLexer.reserved_word?(str) str =~ /\A(?:if|ifdef|ifndef|else|elif|endif|include|include_next|define|defined|undef|line|error|warning|pragma)\Z/ end |
Instance Method Details
#shift ⇒ Object
394 395 396 |
# File 'lib/dbc/ctokenizer.rb', line 394 def shift CPLexer.convert_token(super) end |