VBScript 部分解析器
我正在尝试创建一个 VBScript 解析器。我想知道最好的方法是什么。我研究过、研究过。最流行的方法似乎是使用 Gold Parser 或 ANTLR 之类的东西。
我想要实现的功能是动态检查 VBScript 中的语法错误。我不想每次更改某些文本时都编译整个 VBS。我该如何去做呢?我尝试使用 Gold Parser,但我认为没有增量方法可以通过它进行解析,例如部分解析树...关于如何针对这种情况实现部分解析树有什么想法吗?
我已经通过 GOLD Parser 实现了 VBscript 解析。然而它仍然不是一个部分解析器,在每次文本更改后解析整个脚本。有没有办法构建这样的东西。
谢谢
I am trying to create a VBScript parser. I was wondering what is the best way to go about it. I have researched and researched. The most popular way seems to be going for something like Gold Parser or ANTLR.
The feature I want to implement is to do dynamic checking of Syntax Errors in VBScript. I do not want to compile the entire VBS every time some text changes. How do I go about doing that? I tried to use Gold Parser, but i assume there is no incremental way of doing parsing through it, something like partial parse trees...Any ideas on how to implement a partial parse tree for such a scenario?
I have implemented VBscript Parsing via GOLD Parser. However it is still not a partial parser, parses the entire script after every text change. Is there a way to build such a thing.
thks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您确实想进行增量解析,请考虑 这篇论文,作者:Tim Wagner。
保留现有的解析树,在编辑点打乱字符串片段的混合物,并表示源文本中未更改的部分的解析树,并将字符串重新集成到解析树集中,这是一个绝妙的方案。这是使用增量 GLR 解析器完成的。
实施起来并不容易;我只做了 GLR 部分,从来没有抽出时间来处理增量部分。
GLR 部分的麻烦是值得的。
有很多关于增量解析的论文。这是真正好的之一。
If you really want to do incremental parsing, consider this paper by Tim Wagner.
It is brilliant scheme to keep existing parse trees around, shuffling mixtures of string fragments at the points of editing and parse trees representing the parts of the source text that hasn't changed, and reintegrating the strings into the set of parse trees. It is done using an incremental GLR parser.
It isn't easy to implement; I did just the GLR part and never got around to the incremental part.
The GLR part was well worth the trouble.
There are lots of papers on incremental parsing. This is one of the really good ones.
我首先会寻找现有的 VBScript 解析器,而不是编写自己的解析器,这不是一项简单的任务!
此页面上有 BNF 格式的 VBScript 语法:http://rosettacode.org/wiki/BNF_Grammar 其中您可以将其转换为 ANTLR(或其他解析器生成器)语法。
在尝试做一些奇特的事情(例如仅重新解析源代码的一部分)之前,我建议您首先创建一个实际有效的解析器。
祝你好运!
I'd first look for an existing VBScript parser instead of writing your own, which is not a trivial task!
Theres a VBScript grammar in BNF format on this page: http://rosettacode.org/wiki/BNF_Grammar which you can translate into a ANTLR (or some other parser generator) grammar.
Before trying to do fancy things like re-parsing only a part of the source, I recommend you first create a parser that actually works.
Best of luck!