Class: Nendo::CharReader

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

Instance Method Summary collapse

Constructor Details

#initialize(inport, sourcefile) ⇒ CharReader

Returns a new instance of CharReader.



38
39
40
41
42
# File 'lib/nendo/ruby/reader.rb', line 38

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

Instance Method Details

#columnObject



76
77
78
# File 'lib/nendo/ruby/reader.rb', line 76

def column
  @column
end

#getcObject



49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/nendo/ruby/reader.rb', line 49

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



72
73
74
# File 'lib/nendo/ruby/reader.rb', line 72

def lineno
  @lineno
end

#resetObject



44
45
46
47
# File 'lib/nendo/ruby/reader.rb', line 44

def reset
  @lineno = 1
  @column = 1
end

#sourcefileObject



68
69
70
# File 'lib/nendo/ruby/reader.rb', line 68

def sourcefile
  @sourcefile
end

#ungetc(ch) ⇒ Object



62
63
64
65
66
# File 'lib/nendo/ruby/reader.rb', line 62

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