是否有适用于 Javascript 或 PHP 的解析表达式语法 (PEG) 库?
我发现自己对描述领域特定语言的解析表达式语法形式很感兴趣,但到目前为止,我发现的实现代码是用 Java 和 Haskell 等语言编写的,这些语言在我的组织的共享托管环境中对 Web 服务器不友好必须忍受。
有谁知道适用于 Javascript 或 PHP 的 PEG 库或 PackRat 解析器生成器吗? 当然,任何可以生成 Javascript 或 PHP 源代码的语言的代码生成器都可以做到这一点。
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 languages like Java and Haskell that aren't web server friendly in the shared hosting environment that my organization has to live with.
Does anyone know of any PEG libraries or PackRat Parser Generators for Javascript or PHP? Of course code generators in any languages that can produce Javascript or PHP source code would do the trick.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
我最近编写了 PEG.js,这是一个基于 PEG 的 JavaScript 解析器生成器。 它可以从命令行使用,也可以从浏览器尝试。
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.
事实上,有一个适用于 Javascript 的工具:OMeta。 http://www.tinlizzie.org/ometa/
我还在Python中实现了这个版本: http://github.com/python-parsley/parsley
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
有 php PEG (这是一个维护的分支)
这篇文章确实很旧,但我找到了它通过谷歌,应该已经得到答复
There is php PEG (this is a maintained fork)
This post is really old but I found it through Google, and It should have been answered
Language.js:
Language.js:
看看https://github.com/leblancmeneses/NPEG可以轻松转换成php。
解析树是用匿名函数创建的。
look at https://github.com/leblancmeneses/NPEG can easily be converted into php.
Parse tree is created with anonymous functions.
还有用于 JavaScript 的 Kouprey,这是一个非常易于使用的 PEG 生成器/库。
There's also Kouprey for JavaScript, which is a very easy to use PEG generator/library.
你看过ANTLR吗?它生成词法分析器和解析器代码,处理抽象语法树,允许您插入要注入到词法分析器/解析器代码中的语法代码,并且它可用于多种语言!
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!