Permalink
Browse files

Make use of new inner classes support to bring test case closer to re…

…al Scanner implementation
  • Loading branch information...
vidarh committed Sep 21, 2014
1 parent 6ceb215 commit 960f1b0e6cb1fed4fc72a685f1ff5cf18fdff6aa
Showing with 37 additions and 34 deletions.
  1. +37 −34 features/inputs/scanner6.rb
@@ -1,49 +1,52 @@
class ScannerString < String
def position= newp
@position = newp
end
class Scanner
def position
@position
end
class ScannerString < String
def position= newp
@position = newp
end
def is_a? c
# FIXME:
# Temp hack to make Scanner#unget work
return true
end
end
def position
@position
end
class Position
def initialize filename,lineno,col
@filename = filename
@lineno = lineno
@col = col
def is_a? c
# FIXME:
# Temp hack to make Scanner#unget work
return true
end
end
def lineno
@lineno
end
class Position
def initialize filename,lineno,col
@filename = filename
@lineno = lineno
@col = col
end
def col
@col
end
def lineno
@lineno
end
def filename
@filename
end
def col
@col
end
def inspect
"line #{self.lineno}, col #{self.col} in #{self.filename}"
end
def filename
@filename
end
def inspect
"line #{self.lineno}, col #{self.col} in #{self.filename}"
end
def to_s
inspect
def to_s
inspect
end
end
end
class Scanner
def initialize(io)
# set filename if io is an actual file (instead of STDIN)

0 comments on commit 960f1b0

Please sign in to comment.