Class: Nendo::CharReader

Inherits:
Object
  • Object
show all
Defined in:
lib/nendo.rb

Instance Method Summary collapse

Constructor Details

#initialize(inport, sourcefile) ⇒ CharReader

Returns a new instance of CharReader.



271
272
273
274
275
# File 'lib/nendo.rb', line 271

def initialize( inport, sourcefile )
  @inport     = inport
  @sourcefile = sourcefile
  self.reset
end

Instance Method Details

#columnObject



309
310
311
# File 'lib/nendo.rb', line 309

def column
  @column
end

#getcObject



282
283
284
285
286
287
288
289
290
291
292
293
# File 'lib/nendo.rb', line 282

def getc
  @undo_lineno = @lineno
  @undo_column = @column
  ch = @inport.getc
  if nil != ch
    if ch.chr.match( /[\r\n]/ )
      @lineno += 1
    end
    @column += 1
  end
  ch
end

#linenoObject



305
306
307
# File 'lib/nendo.rb', line 305

def lineno
  @lineno
end

#resetObject



277
278
279
280
# File 'lib/nendo.rb', line 277

def reset
  @lineno = 1
  @column = 1
end

#sourcefileObject



301
302
303
# File 'lib/nendo.rb', line 301

def sourcefile
  @sourcefile
end

#ungetc(ch) ⇒ Object



295
296
297
298
299
# File 'lib/nendo.rb', line 295

def ungetc( ch )
  @lineno = @undo_lineno
  @column = @undo_column
  @inport.ungetc( ch )
end