编译原理实践
The Super Tiny Compiler 超小型编译器 The Super Tiny Compiler 是一个仅有约 1000 行代码的迷你编译器,可用于把 LISP 语言编译成我们熟悉的 JavaScript 语言。
OCaml
lexer(词法分析)
parser(语法解析)
Coco/R 较早的一个语法分析器生成工具。其生成语法分析器的语言极其之多,包括C#、 Java、 C++、F#、VB.Net、Oberon等等。
JavaCC :开源语法解析
Grammatica is a C# and Java parser generator (compiler compiler)
esprima js词法语法解析
> var esprima = require('esprima');
> var program = 'const answer = 42';
> esprima.tokenize(program);
[ { type: 'Keyword', value: 'const' },
{ type: 'Identifier', value: 'answer' },
{ type: 'Punctuator', value: '=' },
{ type: 'Numeric', value: '42' } ]
> esprima.parseScript(program);
{ type: 'Program',
body:
[ { type: 'VariableDeclaration',
declarations: [Object],
kind: 'const' } ],
sourceType: 'script' }