So, I am trying to learn me a bit of ruby, a bit of TDD and a bit of Treetop.
I have the following grammar for parsing string literals:
grammar Str
rule string
'"'
(
!'"' . / '\"'
)*
'"'
end
end
And the following test method:
def test_strings
assert @parser.parse('"Hi there!"')
assert !@parser.parse('"This is not" valid')
assert @parser.parse('"He said, \"Well done!\""')
end
The third test (the one with the backslashes) does not pass (the string is not parsed): why?
Thanks!