Are there any Parsing Expression Grammar (PEG) libraries for Javascript or PHP?

前端 未结 7 1857
野趣味
野趣味 2020-12-31 03:56

I find myself drawn to the Parsing Expression Grammar formalism for describing domain specific languages, but so far the implementation code I\'ve found has been written in

相关标签:
7条回答
  • 2020-12-31 04:22

    Have you looked at ANTLR? It produces lexer and parser code, handles abstract syntax trees, lets you insert code the grammar to be injected into the lexer/parser code, and its available for a variety of languages!

    0 讨论(0)
  • 2020-12-31 04:23

    There is in fact one for Javascript: OMeta. http://www.tinlizzie.org/ometa/

    I also implemented a version of this in Python: http://github.com/python-parsley/parsley

    0 讨论(0)
  • 2020-12-31 04:27

    php PEG https://github.com/maetl/php-peg

    This post is really old but I found it through google, and It should have been answered

    0 讨论(0)
  • 2020-12-31 04:29

    look at https://github.com/leblancmeneses/NPEG can easily be converted into php. Parse tree is created with anonymous functions.

    0 讨论(0)
  • 2020-12-31 04:35

    There's also Kouprey for JavaScript, which is a very easy to use PEG generator/library.

    0 讨论(0)
  • 2020-12-31 04:36

    I have recently written PEG.js, PEG-based parser generator for JavaScript. It can be used from a command-line or you can try it from your browser.

    0 讨论(0)
提交回复
热议问题