|
|
@ -1,4 +1,15 @@
|
|
|
|
PEG.compiler = {
|
|
|
|
PEG.compiler = {
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* Names of passes that will get run during the compilation (in the specified
|
|
|
|
|
|
|
|
* order).
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
appliedPassNames: [
|
|
|
|
|
|
|
|
"reportMissingRules",
|
|
|
|
|
|
|
|
"reportLeftRecursion",
|
|
|
|
|
|
|
|
"removeProxyRules",
|
|
|
|
|
|
|
|
"computeStackDepths"
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Generates a parser from a specified grammar AST. Throws |PEG.GrammarError|
|
|
|
|
* Generates a parser from a specified grammar AST. Throws |PEG.GrammarError|
|
|
|
|
* if the AST contains a semantic error. Note that not all errors are detected
|
|
|
|
* if the AST contains a semantic error. Note that not all errors are detected
|
|
|
@ -6,15 +17,8 @@ PEG.compiler = {
|
|
|
|
* cause its malfunction.
|
|
|
|
* cause its malfunction.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
compile: function(ast) {
|
|
|
|
compile: function(ast) {
|
|
|
|
var PASS_NAMES = [
|
|
|
|
for (var i = 0; i < this.appliedPassNames.length; i++) {
|
|
|
|
"reportMissingRules",
|
|
|
|
this.passes[this.appliedPassNames[i]](ast);
|
|
|
|
"reportLeftRecursion",
|
|
|
|
|
|
|
|
"removeProxyRules",
|
|
|
|
|
|
|
|
"computeStackDepths"
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < PASS_NAMES.length; i++) {
|
|
|
|
|
|
|
|
this.passes[PASS_NAMES[i]](ast);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var source = this.emitter(ast);
|
|
|
|
var source = this.emitter(ast);
|
|
|
|