Class: CTokenizer::CLexer
Overview
C Lexer
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from LexerBase
#empty?, #file, #initialize, #line
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
Constructor Details
This class inherits a constructor from CTokenizer::LexerBase
Class Method Details
.convert_token(t) ⇒ Object
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 |
# File 'lib/dbc/ctokenizer.rb', line 316 def CLexer.convert_token(t) case t[0] when :SYMBOL t = case t[1] when '<:' '[' when ':>' ']' when '<%' '{' when '%>' '}' else t[1] end # case t = [t, t].freeze when :IDENTIFIER if CLexer.reserved_word?(t[1]) t = [t[1], t[1]].freeze end end #case t end |
.reserved_word?(str) ⇒ Boolean
312 313 314 |
# File 'lib/dbc/ctokenizer.rb', line 312 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
340 341 342 |
# File 'lib/dbc/ctokenizer.rb', line 340 def shift CLexer.convert_token(super) end |