namarara/lib/mm2ep_depend/lexer.rb

31 lines
656 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-12 15:25:16 +00:00
ignore "\t\n "
# token :SPACE, /\s+/
2017-09-07 15:05:06 +00:00
token :L_PAR, /\(/
2017-09-12 14:18:23 +00:00
token :R_PAR, /\)/
2017-09-07 15:05:06 +00:00
token :NUMBER, /[0-9]+(\.[0-9]+)?/
2017-09-12 15:33:07 +00:00
token :STRING, /"([^"]*)"/ do |s|
s.value.gsub!(/"(.*)"/, '\1')
2017-09-12 15:33:07 +00:00
s
end
2017-09-07 15:05:06 +00:00
token :EQ_OP, /\=/
2017-09-12 15:09:53 +00:00
token :T_BOOL, /true/i
token :F_BOOL, /false/i
2017-09-07 15:05:06 +00:00
token :VAR, /[a-z][a-zA-Z0-9_]+/
token :AND_OP, /AND/
token :OR_OP, /OR/
token :NOT_OP, /NOT/
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