Class: Fusion::Lexer
- Inherits:
-
Object
- Object
- Fusion::Lexer
- Defined in:
- lib/fusion.rb
Constant Summary collapse
- PUNCT =
{ "(" => :lparen, ")" => :rparen, "[" => :lbracket, "]" => :rbracket, "{" => :lbrace, "}" => :rbrace, "," => :comma, ":" => :colon, "|" => :pipe, "?" => :question, "." => :dot, "@" => :at, "/" => :slash, }.freeze
Instance Method Summary collapse
-
#initialize(src) ⇒ Lexer
constructor
A new instance of Lexer.
- #tokens ⇒ Object
Constructor Details
#initialize(src) ⇒ Lexer
Returns a new instance of Lexer.
57 58 59 60 61 |
# File 'lib/fusion.rb', line 57 def initialize(src) @src = src @i = 0 @n = src.length end |
Instance Method Details
#tokens ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/fusion.rb', line 63 def tokens out = [] loop do t = next_token out << t break if t.type == :eof end out end |