Class: RubyLexer::SimpleTokenPrinter
- Inherits:
-
Object
- Object
- RubyLexer::SimpleTokenPrinter
- Defined in:
- lib/rubylexer/tokenprinter.rb
Overview
Constant Summary collapse
- TOKENSPERLINE =
8
- TOKENSMAGICMAP =
"\n"+' '*(TOKENSPERLINE-1)
Instance Method Summary collapse
-
#initialize(*bogus) ⇒ SimpleTokenPrinter
constructor
A new instance of SimpleTokenPrinter.
- #pprint(tok, output = $stdout) ⇒ Object
- #sprint(tok) ⇒ Object
Constructor Details
#initialize(*bogus) ⇒ SimpleTokenPrinter
Returns a new instance of SimpleTokenPrinter.
30 31 32 |
# File 'lib/rubylexer/tokenprinter.rb', line 30 def initialize(*bogus) @tokens=@srclines=0 end |
Instance Method Details
#pprint(tok, output = $stdout) ⇒ Object
37 |
# File 'lib/rubylexer/tokenprinter.rb', line 37 def pprint(tok,output=$stdout) output.print(sprint(tok)) end |
#sprint(tok) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/rubylexer/tokenprinter.rb', line 39 def sprint(tok) case tok when Newline then "#{@lastfal if ((@srclines+=1)%16==0)} #; " when FileAndLineToken then @lastfal=tok;'' when IgnoreToken then '' #skip comments&whitespace else tok.to_s + TOKENSMAGICMAP[ (@tokens+=1) % TOKENSPERLINE, 1 ] end end |