自 5.0 以来,Gold Parser 改变了它处理共享一个结束终端的多个组的方式。这会导致您使用的定义不起作用(我假设您刚刚删除了 Rem 部分以便构建语法?)
自 5.0 以来有两个主要变化:
由于将使用已定义的换行符,因此如果需要换行符,将自动声明换行符。(如评论)。
Comment+X 将自动归类为“噪声”,并在解析时将其删除,为了避免将注释定义为噪声,您需要明确告诉它它是解析器逻辑必不可少的东西。
此外,您使用的代码只找到了注释开头但没有做任何事情,为了在找到 ' 符号后“捕获”任何内容,我们需要声明我们正在寻找的内容。您可以通过以下方式完成此操作:
! Special Whitespace definition ( All Whitespace's excluding new-lines )
{WS} = {Whitespace} - {CR} - {LF}
! Special Comment Line definition ( All words,special White-spaces and defined symbols until a Line Break is found )
Comment Line = ''({Alphanumeric} | {WS} | [.,-+="] )*{All Newline}
Rem Line = rem
Comment Line @= {type= Content}
Rem @= {type = Content }
这样,两者都被声明为两个基于行的组(注释行和 Rem 行),我们将两者都定义为 Content 类型,导致两者都被视为 Content 而不是默认的噪音。(因此不应被解析器删除)。
希望这有助于进一步阅读:
http://goldparser.org/doc/grammars/define-groups.htm
http://goldparser.org/doc/grammars/group-attributes.htm
http://goldparser.org/doc/grammars/example-group.htm