谁能告诉我如何在支持两者的Treetop上编写语法:
system u AAA1 car=5, motor=4
和
system u car=5, motor=4
您想使用“可选表达式”(请参阅此页面上大约 60% 的内容):
grammar Sokmesa
rule line
"system" wsp+ marker wsp+ (category wsp+)? attributelist
end
rule category
"AAA1" # Or whatever
end
# Add rules for 'marker', 'wsp', and 'attributelist' here
end