|
|
|
@ -1,16 +1,27 @@
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
let arrays = require("../utils/arrays"),
|
|
|
|
|
visitor = require("./visitor");
|
|
|
|
|
let visitor = require("./visitor");
|
|
|
|
|
|
|
|
|
|
/* AST utilities. */
|
|
|
|
|
let asts = {
|
|
|
|
|
findRule: function(ast, name) {
|
|
|
|
|
return arrays.find(ast.rules, r => r.name === name);
|
|
|
|
|
for (let i = 0; i < ast.rules.length; i++) {
|
|
|
|
|
if (ast.rules[i].name === name) {
|
|
|
|
|
return ast.rules[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return undefined;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
indexOfRule: function(ast, name) {
|
|
|
|
|
return arrays.indexOf(ast.rules, r => r.name === name);
|
|
|
|
|
for (let i = 0; i < ast.rules.length; i++) {
|
|
|
|
|
if (ast.rules[i].name === name) {
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
alwaysConsumesOnSuccess: function(ast, node) {
|
|
|
|
|