【发布时间】:2012-12-07 01:23:05
【问题描述】:
我是 Treetop 的新手,我有一个非常简单的语法,我就是无法使用。我有一些测试:
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
这是我的语法:
grammar BBCode
rule open_tag
"[" tag_name "]"
end
rule tag_name
[a-zA-Z\*]+
end
rule close_tag
"[/" tag_name "]"
end
end
第一个测试通过,第二个测试失败。我还尝试了这些替代规则:
"[" [\/] tag_name "]"
"[" "/" tag_name "]"
"[\/" tag_name "]"
所有这些都失败了。
无论我尝试什么,我似乎都无法让它识别结束标签。
【问题讨论】:
-
嗯...查看mathematica grammar 中的规则“div”,它有一个
'/',它似乎有效。 -
我见过很多这样的例子。因此我感到困惑:/