使用 ANTLR 生成词法分析器/解析器作为流 [英] Using ANTLR to generate lexer/parser as streams

查看:23
本文介绍了使用 ANTLR 生成词法分析器/解析器作为流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用 ANTLR Java API 将词法分析器/解析器生成为流并将它们保存在某些文件以外的地方吗?

Can I use the ANTLR Java API to generate the lexer/parser as streams and save them somewhere other than some files?

另外,是否有使用 API 从给定语法生成所需文件的简单示例?

Also, is there a simple example of using the API to generate the required files from a given grammar?

谢谢

推荐答案

我不能 100% 确定我是否正确理解了您的问题,但您可能想看看 https://stackoverflow.com/a/38052798/5068458.这是一个用于 antlr 语法的内存编译器,它为内存中的给定语法生成词法分析器和解析器.您不必手动执行此操作.那里提供了代码示例.

I am not 100% sure if I understand your question correctly, but you might want to have a look at https://stackoverflow.com/a/38052798/5068458. This is an in-memory compiler for antlr grammars that generates lexer and parser for a given grammar in-memory. You do not have to do it manually. Code examples are provided there.

最好的,朱利安

这篇关于使用 ANTLR 生成词法分析器/解析器作为流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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