使用Javascript编写解析器的教程 [英] Tutorials for writing a parser with Javascript
问题描述
我见过几种语言(即 CoffeeScript 和 LessCSS )基于Javascript构建。
I've seen a couple of languages (namely CoffeeScript and LessCSS) that are built on Javascript.
是否有使用Javascript编写语言/解析器的教程?
Are there tutorials anywhere for writing languages/parsers with Javascript?
推荐答案
Jison 以GNU Bison解析器生成器为模型。它采用类似Bison或JSON格式的语言语法,并为该语言输出Javascript解析器。如果你想要建立一个基于另一种着名语言的翻译,可能会有一个Bison语法在你可以为Jison调整的地方。
我发现从头开始使用DSL非常简单。
Jison is modeled on the GNU Bison parser generator. It takes a language grammar in Bison-like or JSON format and outputs a Javascript parser for the language. If you're wanting to make an interpreter that's based on on another well-known language, there's probably a Bison grammar around somewhere you can tweak for Jison. I've found it very straightforward to get started on a from-scratch DSL.
这篇关于使用Javascript编写解析器的教程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!