Tom Aadland wrote:
Thank you for responding and I’m sorry I didn’t provide more
information.
Not a problem, we’re here to help 
I thought that the ‘foo’ &‘bar’ rule meant that bar has to come togehter
with foo as in foobar and on top of that not really consume bar so that
the text_value returned would only be foo.
That’s correct.
However the following test below runs fine with that in mind 
Your test doesn’t ask for that, it asks that foo should be followed
by a sequence of one or more of any character, starting with bar,
and it consumes all that input.
What I want with this rule is: match foobar or even foobarsomething, but
return the textvalue without bar.
I believe the only problem with your original rule is that by default,
for a Treetop parse to succeed, all input must be consumed. If you
change to the following:
parser = FooGrammarParser.new
parser.consume_all_input = false
res = parser.parse(“foobar”)
then the original rule (“foo” &“bar”) will match and return “foo”,
without the parse failing due to not having consumed all input.
You should always print “parser.failure_reason” when a parse fails,
it’ll tell you how far the parser got and what input would have allowed
it to get further.
Also, a common trap for new Treetoppers is to forget that matching is
greedy. For that reason, you almost never want to say “.*” or “.+”
because those will consume all input and leave nothing for subsequent
rules to even look at. For for example, this rule will always fail:
rule big_fail
‘foo’ .* ‘bar’
end
This must be rewritten, for example like this:
rule ok
'foo (!‘bar’ .)* ‘bar’
end
Clifford H…