简体   繁体   English

VBScript部分解析器

[英]VBScript Partial Parser

I am trying to create a VBScript parser. 我正在尝试创建一个VBScript解析器。 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. 最流行的方式似乎是像Gold Parser或ANTLR这样的东西。

The feature I want to implement is to do dynamic checking of Syntax Errors in VBScript. 我想实现的功能是动态检查VBScript中的语法错误。 I do not want to compile the entire VBS every time some text changes. 每次文本更改时,我都不想编译整个VBS。 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? 我尝试使用Gold Parser,但我认为没有增量方法可以通过它进行解析,比如部分解析树...有关如何为这种情况实现部分解析树的任何想法?

I have implemented VBscript Parsing via GOLD Parser. 我通过GOLD Parser实现了VBscript Parsing。 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 THKS

If you really want to do incremental parsing, consider this paper by Tim Wagner. 如果你真的想进行增量解析,请考虑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. 它是使用增量GLR解析器完成的。

It isn't easy to implement; 实施起来并不容易; I did just the GLR part and never got around to the incremental part. 我只做了GLR部分而且从未接触过增量部分。 The GLR part was well worth the trouble. GLR部分值得一试。

There are lots of papers on incremental parsing. 有很多关于增量解析的论文。 This is one of the really good ones. 这是非常好的一个。

I'd first look for an existing VBScript parser instead of writing your own, which is not a trivial task! 我首先寻找一个现有的VBScript解析器,而不是编写自己的,这不是一个简单的任务!

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. 这个页面上有一个BNF格式的VBScript语法: http//rosettacode.org/wiki/BNF_Grammar ,您可以将其转换为ANTLR(或其他一些解析器生成器)语法。

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! 祝你好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM