我们什么时候使用 ANTLR [英] When do we use ANTLR

查看:39
本文介绍了我们什么时候使用 ANTLR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能指导我在 ASP.Net、C# 项目中使用 ANTLR dll 的目的.

Can anyone please guide me the purpose of using ANTLR dlls in a ASP.Net, C# project.

我刚刚注意到在某些项目中引用了 antlr.runtimeAntlr3.RuntimeAntlr3.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.

这篇关于我们什么时候使用 ANTLR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆