Sha256: 76063837f9a0e59d8c326e0bee77e7a6aec25a023f227eb1c686ab74f8c57b97

Contents?: true

Size: 712 Bytes

Versions: 1

Compression:

Stored size: 712 Bytes

Contents

#!/usr/bin/env ruby -dw
require 'rubylexer'
require 'getoptlong'



#a Token#inspect that omits the object id
class Token
  def inspect
    ["#<",self.class,": ",instance_variables.sort.collect{|v| 
      [v,"=",instance_variable_get(v).inspect," "]
    }].to_s.sub(/ $/,'>')
  end
end

file=nil

#allow -e
opts=GetoptLong.new(["--eval", "-e", GetoptLong::REQUIRED_ARGUMENT])
opts.each{|opt,arg|
  opt=='--eval' or raise :impossible
  file=arg
  name='-e'
}
     
#determine input file and its name if not already known
file||=if name=ARGV.first
    File.open(name)
  else 
    name='-'
    $stdout
  end

lexer=RubyLexer.new(name, file) 
until EoiToken===(tok=lexer.get1token)
  p tok
end
p tok #print eoi token

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubylexer-0.6.2 testcode/dumptokens.rb