我们什么时候使用 ANTLR
谁能指导我在 ASP.Net、C# 项目中使用 ANTLR dll 的目的.
Can anyone please guide me the purpose of using ANTLR dlls in a ASP.Net, C# project.
我刚刚注意到在某些项目中引用了 antlr.runtime、Antlr3.Runtime、Antlr3.Utlility 程序集.
I just noticed antlr.runtime, Antlr3.Runtime, Antlr3.Utlility assemblies being referenced in some project.
如果能引用一些真实世界的例子或者任何指向网页的链接都会有用,那就太好了.
Will be great if can cite some real world examples or any link to a web page will be useful.
如果您在运行时使用 antlr 语法解析任何文本,您将需要这些 dll.
You would need these dll's if you are parsing any text at runtime using an antlr grammar.
通常有两个步骤.
1) 在 .g 文件上运行 java antlr 解析器以生成 C# 词法分析器、C# 语法和可能的 C# 树遍历器.
1) run the java antlr parser over your .g files to generate a C# lexer, C# grammar and possibly C# tree walkers.
2) 将这些文件构建到您的应用程序中.如果您使用的是 ANTLR 版本 3,这些文件将与 antlr.runtime dll 或 antlr3.runtime dll 一起使用.
2) Build those files into your application. Those files will work in conjunction with the antlr.runtime dll, or antlr3.runtime dll if you're using ANTLR version 3.
您的 C# 程序现在可以使用您在步骤 1 中编译的语法来解析文本文件.
Your C# program can now parse text files using the grammar that you compiled in step 1.