从 GOLD-Parser CGT 文件中提取关键字
我定义了一个包含许多规则的语法,它使用了许多关键字。想象一下这样(只是有更多的规则和更多的关键字):
<keyword> ::= 'public' | 'protected' | 'private'
gold-parser-system 正在生成一个编译的语法表(CGT)文件,该文件由多个引擎使用,在我的例子中是 c# 的 calitha-engine 。
为了实现我想要解析的源代码的语法突出显示,我想获取一系列规则的所有关键字。我如何提取它们?
i have defined a grammar with many rules, that uses many keywords. imagine it like this (just with more of these rules and more keywords):
<keyword> ::= 'public' | 'protected' | 'private'
the gold-parser-system is generating a compiled grammar table (CGT) file, which is used by the several engines, in my case the calitha-engine for c#.
in order to realize some syntax-highlighting for my sourcecode which i want to parse, i want to get all the keywords of a range of rules. how do i extract them?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
除了生成“cgt”输出文件外,Gold Builder 还具有 XML 输出功能。
如果您对 XML 处理感到满意,我建议您使用 XML 提取关键字作为一种可能的解决方案(请参阅文档)。
下面是一个示例语法 XML 文件:
XML 作为人类可读格式是不言自明的,您可以访问所有表:符号、规则、DFA 和 LALR,仅此而已。
当然,烹饪“pgt”文件(程序模板)是处理“cgt”的常用方法,甚至在黄金引擎之上为此目的编写一些提取实用程序。
Apart from generating "cgt" output file, Gold Builder has also XML output capability.
If you feel comfortable with XML processing, I suggest you to extract the keywords using XML as one possible solution (See documentation).
Here is a sample grammar XML file :
XML as human readable format is self explanatory, you have access to all tables : Symbol, Rule, DFA and LALR and that's it.
Of course, cooking a "pgt" file (program template) is the usual way to process "cgt" or even write some extract utility for the purpose on top of a Gold Engine.