L
Lex Williams
Hi guys !
I started to learn to use treetop , so I would have a question :
if I create a grammar this way :
grammar Tester
rule basic
([a-f] [a-f] [a-f] [a-f] [a-f]) {
def val
text_value
end
}
end
end
and use it in the following code :
require "rubygems"
require "treetop"
Treetop.load "tester"
parser = TesterParser.new
puts parser.parse("abcde").val
I get the following error : x.rb:6: undefined method `val' for
#<Treetop::Runtime::SyntaxNode:0xb7ccd4b0> (NoMethodError) . However ,
if I replace this :
([a-f] [a-f] [a-f] [a-f] [a-f])
with
([a-f] [a-f] [a-f] [a-f] [a-f] / '')
then everything works . Could you explain why this happens ?
I started to learn to use treetop , so I would have a question :
if I create a grammar this way :
grammar Tester
rule basic
([a-f] [a-f] [a-f] [a-f] [a-f]) {
def val
text_value
end
}
end
end
and use it in the following code :
require "rubygems"
require "treetop"
Treetop.load "tester"
parser = TesterParser.new
puts parser.parse("abcde").val
I get the following error : x.rb:6: undefined method `val' for
#<Treetop::Runtime::SyntaxNode:0xb7ccd4b0> (NoMethodError) . However ,
if I replace this :
([a-f] [a-f] [a-f] [a-f] [a-f])
with
([a-f] [a-f] [a-f] [a-f] [a-f] / '')
then everything works . Could you explain why this happens ?