1
我是Treetop的新手,並且有一個非常簡單的語法,我只是無法工作。我有一些測試: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 "]"
所有這些都失敗。
我似乎無法讓它識別結束標記,無論我嘗試什麼。
嗯......看在規則「DIV」 [mathematica語法](https://github.com/farleyknight/mathematica_parser/blob/master/lib/mathematica.treetop),它有一個''/'',它似乎工作。 –
我見過很多的例子。因此,我的困惑:/ – DVG