Class: CTokenizer::CPLexer
Overview
C Preprocessor Lexer
Constant Summary
Constants included from CTokenizer
Instance Attribute Summary
Attributes inherited from LexerBase
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from LexerBase
#empty?, #file, #initialize, #line, #match?, #post_match, #scan
Methods included from CTokenizer
check_token, #collect, #each, #error, error, line_count, #parse_error, #to_a, #token_error, #warning, whitespace?
Constructor Details
This class inherits a constructor from CTokenizer::LexerBase
Class Method Details
.convert_token(t) ⇒ Object
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 |
# File 'lib/dbc/ctokenizer.rb', line 366 def CPLexer.convert_token(t) str = t[1] case t[0] when :SYMBOL case str when '!', '*', '/', '%', '+', '-', \ '<<', '>>', '(', ')', \ '<', '<=', '>', '>=', '==', '!=', \ '&', '^', '|', '&&', '||', \ '?', ':', '#', '##', '...', ',' t = [str, str].freeze end # case when :IDENTIFIER if CPLexer.reserved_word?(str) t = [str, str].freeze end end # case t end |
.reserved_word?(str) ⇒ Boolean
362 363 364 |
# File 'lib/dbc/ctokenizer.rb', line 362 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
386 387 388 |
# File 'lib/dbc/ctokenizer.rb', line 386 def shift CPLexer.convert_token(super) end |