I'm new to Treetop, and have a very simple grammar that I just can't make work. I have some tests:
it "parses a open tag as some text surrouded by brackets" do
document = "[b]"
Parser.parse(document).should_not be_nil
end
it "parses a close tag as a tag with a / preceeding the tag name" do
document = '[/b]'
Parser.parse(document).should_not be_nil
end
This is my grammar:
grammar BBCode
rule open_tag
"[" tag_name "]"
end
rule tag_name
[a-zA-Z\*]+
end
rule close_tag
"[/" tag_name "]"
end
end
The first test passes, the second test fails. I also tried these alternate rules:
"[" [\/] tag_name "]"
"[" "/" tag_name "]"
"[\/" tag_name "]"
all of which fail.
I can't seem to get it to recognize the closing tag no matter what I try.