fdelente
6/22/2008 8:30:00 AM
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