Combined unparser/parser generator

后端 未结 5 959
孤街浪徒
孤街浪徒 2021-02-02 15:08

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 k

5条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-02 15:49

    There are several parser generators that include an implementation of an unparser. One of them is the nearley parser generator for context-free grammars.

    It is also possible to implement bidirectional transformations of source code using definite clause grammars. In SWI-Prolog, the phrase/2 predicate can convert an input text into a parse tree and vice-versa.

提交回复
热议问题