Class: IgniterLang::Lexer
- Inherits:
-
Object
- Object
- IgniterLang::Lexer
- Defined in:
- lib/igniter_lang/parser.rb
Instance Method Summary collapse
-
#initialize(source) ⇒ Lexer
constructor
A new instance of Lexer.
- #tokenize ⇒ Object
Constructor Details
#initialize(source) ⇒ Lexer
Returns a new instance of Lexer.
57 58 59 60 61 62 63 |
# File 'lib/igniter_lang/parser.rb', line 57 def initialize(source) @source = source @pos = 0 @line = 1 @col = 1 @tokens = [] end |
Instance Method Details
#tokenize ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/igniter_lang/parser.rb', line 65 def tokenize until @pos >= @source.length skip_whitespace_and_comments break if @pos >= @source.length tok = next_token @tokens << tok if tok && tok.type != :comment end @tokens << Token.new(:eof, nil, @line, @col) @tokens end |