Class: CTokenizer::SkipMacros
- Includes:
- Scoped
- Defined in:
- lib/dbc/ctokenizer.rb
Overview
Skips macro tokens - NOT lossy - converts macro into a single newline token
Constant Summary
Constants included from CTokenizer
Instance Attribute Summary
Attributes included from Scoped
Attributes inherited from LexerBase
Instance Method Summary collapse
-
#initialize(str, file = nil, line = 1) ⇒ SkipMacros
constructor
A new instance of SkipMacros.
- #shift ⇒ Object
Methods included from Scoped
#macro?, #process_scope, #start_of_line?
Methods inherited from LexerBase
#empty?, #file, #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
#initialize(str, file = nil, line = 1) ⇒ SkipMacros
Returns a new instance of SkipMacros.
286 287 288 289 290 291 |
# File 'lib/dbc/ctokenizer.rb', line 286 def initialize(str, file=nil, line=1) super(str, file, line) @scope = 0 @macro = false @start_line = true end |
Instance Method Details
#shift ⇒ Object
292 293 294 295 296 297 298 299 300 301 302 303 304 305 |
# File 'lib/dbc/ctokenizer.rb', line 292 def shift t = process_scope(super) if macro? start = self.line token = t[1].dup while macro? and not empty? t = process_scope(super) token << t[1] end self.error("expecting newline") unless empty? or t[0] == :NEWLINE t = [:NEWLINE, token.freeze].freeze end t end |