| Class | Farts::Lexer |
| In: |
lib/farts/farts_lexer.rb
|
| Parent: | StringScanner |
The Lexer class converts the text of a program to tokens
| Keywords | = | %w(if else endif and or end args actor this true false) | Table of keywords and token type values |
# File lib/farts/farts_lexer.rb, line 24 def initialize(str) @token = [:UNKNOWN, nil] super(str) end
# File lib/farts/farts_lexer.rb, line 29 def next_token @token = [:UNKNOWN, nil] scan(/\s+/) check_unary if @token[0] == :UNKNOWN check_binary if @token[0] == :UNKNOWN check_string if @token[0] == :UNKNOWN check_numeric if @token[0] == :UNKNOWN check_ident if @token[0] == :UNKNOWN if @token[0] == :COMMENT @token[1] += skip_line end if @token[0] == :UNKNOWN @token[1] = scan_until(/\s+/) end return [false,false] if eos? return @token end