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

查看:198
本文介绍了使用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%是否能正确理解您的问题,但您可能想看看

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天全站免登陆