namarara/lib/lexer.rb

27 lines
570 B
Ruby
Raw Normal View History

2017-09-04 09:19:29 +00:00
module Mm2ep
module Depend
2017-09-07 15:05:06 +00:00
class Lexer < Rly::Lex
2017-09-04 09:19:29 +00:00
2017-09-07 15:05:06 +00:00
token :L_PAR, /\(/
token :NUMBER, /[0-9]+(\.[0-9]+)?/
token :STRING, /"[^"]*"/
token :EQ_OP, /\=/
token :T_BOOL, /[tT]rue/
token :F_BOOL, /[fF]alse/
token :VAR, /[a-z][a-zA-Z0-9_]+/
token :AND_OP, /AND/
token :OR_OP, /OR/
token :NOT_OP, /NOT/
token :SPACE, /\s+/
token :R_PAR, /\)/
2017-09-04 09:19:29 +00:00
2017-09-07 15:05:06 +00:00
on_error do |t|
puts "Illegal character #{t.value}"
t.lexer.pos += 1
nil
2017-09-04 09:19:29 +00:00
end
end # class
end # module
end # module