Class: CTokenizer::Cache
- Inherits:
-
Object
- Object
- CTokenizer::Cache
- Includes:
- CTokenizer
- Defined in:
- lib/dbc/ctokenizer.rb
Overview
LexerBase
Constant Summary
Constants included from CTokenizer
CP_RESERVED, C_RESERVED, EOF_TOKEN
Instance Attribute Summary collapse
-
#cache ⇒ Object
readonly
Returns the value of attribute cache.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
Instance Method Summary collapse
- #<<(t) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(file = nil, line = 1) ⇒ Cache
constructor
A new instance of Cache.
- #reset(file, line) ⇒ Object
- #shift ⇒ Object
Methods included from CTokenizer
check_token, #collect, #each, #error, error, line_count, #parse_error, #to_a, #token_error, #warning, whitespace?
Constructor Details
#initialize(file = nil, line = 1) ⇒ Cache
Returns a new instance of Cache.
269 270 271 272 273 |
# File 'lib/dbc/ctokenizer.rb', line 269 def initialize(file=nil, line=1) @cache = [] @file = file @line = line end |
Instance Attribute Details
#cache ⇒ Object (readonly)
Returns the value of attribute cache.
274 275 276 |
# File 'lib/dbc/ctokenizer.rb', line 274 def cache @cache end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
274 275 276 |
# File 'lib/dbc/ctokenizer.rb', line 274 def file @file end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
274 275 276 |
# File 'lib/dbc/ctokenizer.rb', line 274 def line @line end |
Instance Method Details
#<<(t) ⇒ Object
279 280 281 |
# File 'lib/dbc/ctokenizer.rb', line 279 def <<(t) @cache << t end |
#empty? ⇒ Boolean
287 288 289 |
# File 'lib/dbc/ctokenizer.rb', line 287 def empty? @cache.empty? end |
#reset(file, line) ⇒ Object
275 276 277 278 |
# File 'lib/dbc/ctokenizer.rb', line 275 def reset(file, line) @file = file @line = line end |
#shift ⇒ Object
282 283 284 285 286 |
# File 'lib/dbc/ctokenizer.rb', line 282 def shift t = @cache.shift @line += CTokenizer.line_count(t[1]) t end |