From: fdelente@... Date: 2008-06-22T17:28:22+09:00 Subject: rex: howto use the lexer class? Hello. I'm trying to get rex to parse my inputs. After reading some of the sample files provided with rex, I created this simple(?) file: file: test.rex------------------------------------------------------------ # -*- ruby -*- ########################################################################## class Lexer macro BLANKS \s+ DIGITS \d+ LETTERS [a-zA-Z]+ rule {BLANKS} {LETTERS} { puts "ID: '@{text}'"; [ :ID, text ] } {DIGITS} { puts "NUMBER: '@{text}'"; [ :NUMBER, text.to_f ] } .|\n { puts "text: '@{text}'"; [ text, text ] } inner end ########################################################################## lexer=Lexer.new while 1 str=$stdin.gets.strip puts "str=@{str}" lexer.scan_str(str) puts "--------------------------------------------------------------------------" end end of file: test.rex----------------------------------------------------- After 'rex test.rex', and 'ruby -Ku test.rex.rb', I always get errors like test.rex.rb:60:in scan_evaluate': can not match: '2' (Lexer::ScanError) when I type input. Can anybody tell me why? Thanks. -- Fabrice DELENTE