Class: Rouge::Reader
- Inherits:
-
Object
- Object
- Rouge::Reader
- Defined in:
- lib/rouge/reader.rb
Defined Under Namespace
Classes: EOFError, EndOfDataError, NumberFormatError, UnexpectedCharacterError
Constant Summary collapse
- @@gensym_counter =
0
Instance Attribute Summary collapse
-
#ns ⇒ Object
Returns the value of attribute ns.
Instance Method Summary collapse
-
#initialize(ns, input) ⇒ Reader
constructor
A new instance of Reader.
- #lex ⇒ Object
Constructor Details
#initialize(ns, input) ⇒ Reader
Returns a new instance of Reader.
14 15 16 17 18 19 |
# File 'lib/rouge/reader.rb', line 14 def initialize(ns, input) @ns = ns @src = input @n = 0 @gensyms = [] end |
Instance Attribute Details
#ns ⇒ Object
Returns the value of attribute ns.
10 11 12 |
# File 'lib/rouge/reader.rb', line 10 def ns @ns end |
Instance Method Details
#lex ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/rouge/reader.rb', line 21 def lex case peek when MAYBE_NUMBER number when /:/ keyword when /"/ string when /\(/ Rouge::Seq::Cons[*list(')')] when /\[/ list ']' when /#/ dispatch when SYMBOL # SYMBOL after \[ and #, because it includes both symbol_or_number when /{/ map when /'/ quotation when /`/ syntaxquotation when /~/ dequotation when /\^/ when /@/ deref when nil reader_raise EOFError, "in #lex" else reader_raise UnexpectedCharacterError, "#{peek.inspect} in #lex" end end |