Class: CTokenizer::CLexer
Overview
C 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
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 |
# File 'lib/dbc/ctokenizer.rb', line 330 def CLexer.convert_token(t) str = t[1] case t[0] when :SYMBOL case str when '<:' str = '[' when ':>' str = ']' when '<%' str = '{' when '%>' str = '}' end # case t = [str, str].freeze when :IDENTIFIER if CLexer.reserved_word?(str) t = [str, str].freeze end end #case t end |
.reserved_word?(str) ⇒ Boolean
326 327 328 |
# File 'lib/dbc/ctokenizer.rb', line 326 def CLexer.reserved_word?(str) str =~ /\A(?:auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|inline|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while)\Z/o end |
Instance Method Details
#shift ⇒ Object
353 354 355 |
# File 'lib/dbc/ctokenizer.rb', line 353 def shift CLexer.convert_token(super) end |