Class: Furud::Formula::Lexer
- Inherits:
-
Object
- Object
- Furud::Formula::Lexer
- Defined in:
- lib/furud/formula.rb
Instance Method Summary collapse
-
#initialize(source, origin) ⇒ Lexer
constructor
A new instance of Lexer.
- #tokens ⇒ Object
Constructor Details
#initialize(source, origin) ⇒ Lexer
Returns a new instance of Lexer.
273 274 275 276 277 |
# File 'lib/furud/formula.rb', line 273 def initialize(source, origin) @source = source @origin = origin @scanner = StringScanner.new(source) end |
Instance Method Details
#tokens ⇒ Object
279 280 281 282 283 284 285 286 287 288 289 |
# File 'lib/furud/formula.rb', line 279 def tokens result = [] until @scanner.eos? @scanner.skip(/\s+/) break if @scanner.eos? position = @scanner.pos result << Token.new(*next_token(position)) end result << Token.new(:eof, nil, @scanner.pos) end |