组合的非解析器/解析器生成器 [英] Combined unparser/parser generator

查看:69
本文介绍了组合的非解析器/解析器生成器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一个解析器生成器也实现相反的方向,即从相同的语法规范中解析域对象(又称漂亮打印)?据我所知,ANTLR不支持此功能.

Is there a parser generator that also implements the inverse direction, i.e. unparsing domain objects (a.k.a. pretty-printing) from the same grammar specification? As far as I know, ANTLR does not support this.

推荐答案

我已经用Java和Kotlin实现了一组Invertible Parser Combinator.解析器几乎是用LL-1样式编写的,它提供了解析和打印方法,后者提供了漂亮的打印机.

I have implemented a set of Invertible Parser Combinators in Java and Kotlin. A parser is written pretty much in LL-1 style and it provides a parse- and a print-method where the latter provides the pretty printer.

您可以在这里找到项目: https://github.com/searles/parsing 这是一个教程: https://github.com/searles/parsing/blob /master/tutorial.md 这是用于数学表达式的解析器/漂亮打印机: https://github.com/searles/parsing/blob/master/src/main/java/at/searles/demo/DemoInvert.kt

You can find the project here: https://github.com/searles/parsing Here is a tutorial: https://github.com/searles/parsing/blob/master/tutorial.md And here is a parser/pretty printer for mathematical expressions: https://github.com/searles/parsing/blob/master/src/main/java/at/searles/demo/DemoInvert.kt

这篇关于组合的非解析器/解析器生成器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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