0

谁能告诉我如何在支持两者的Treetop上编写语法:

system u AAA1 car=5, motor=4

system u car=5, motor=4
4

1 回答 1

2

您想使用“可选表达式”(请参阅​​此页面上大约 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
于 2012-06-12T14:30:52.217 回答