Ruby Treetop 如何包含所有不符合语法的内容
Ruby Treetop how to include everything that does not match the grammar
我正在尝试创建树顶语法。我已经创建了规则来匹配文件中我感兴趣的部分。
grammar Sexp
rule bodies
body+
end
rule body
commentPortString (ifdef_blocks / interface)+ (!newLine)
end
...
end
如何在文件中 运行 提取 bodies
并忽略我不关心的其他部分,或者我是否还需要为这些部分编写规则?
提前致谢
重复匹配不属于规则 !body
的任何字符 .
是 PEG 语法中的常见习语。像这样:
rule bodies
((!body .)* body)+ (!body .)*
end
我正在尝试创建树顶语法。我已经创建了规则来匹配文件中我感兴趣的部分。
grammar Sexp
rule bodies
body+
end
rule body
commentPortString (ifdef_blocks / interface)+ (!newLine)
end
...
end
如何在文件中 运行 提取 bodies
并忽略我不关心的其他部分,或者我是否还需要为这些部分编写规则?
提前致谢
重复匹配不属于规则 !body
的任何字符 .
是 PEG 语法中的常见习语。像这样:
rule bodies
((!body .)* body)+ (!body .)*
end