Class: 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.



136
137
138
139
140
# File 'lib/nendo.rb', line 136

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

Instance Method Details

#columnObject



174
175
176
# File 'lib/nendo.rb', line 174

def column
  @column
end

#getcObject



147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/nendo.rb', line 147

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



170
171
172
# File 'lib/nendo.rb', line 170

def lineno
  @lineno
end

#resetObject



142
143
144
145
# File 'lib/nendo.rb', line 142

def reset
  @lineno = 1
  @column = 1
end

#sourcefileObject



166
167
168
# File 'lib/nendo.rb', line 166

def sourcefile
  @sourcefile
end

#ungetc(ch) ⇒ Object



160
161
162
163
164
# File 'lib/nendo.rb', line 160

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