Browse Source

Make names of compiler checks and passes verbs

redux
David Majda 10 years ago
parent
commit
64d26e5db2
  1. 4
      src/checks.js
  2. 8
      src/compiler.js
  3. 4
      src/passes.js
  4. 4
      test/checks-test.js
  5. 4
      test/passes-test.js

4
src/checks.js

@ -8,7 +8,7 @@
*/
PEG.compiler.checks = {
/* Checks that all referenced rules exist. */
missingReferencedRules: function(ast) {
reportMissingReferencedRules: function(ast) {
function nop() {}
function checkExpression(node) { check(node.expression); }
@ -56,7 +56,7 @@ PEG.compiler.checks = {
},
/* Checks that no left recursion is present. */
leftRecursion: function(ast) {
reportLeftRecursion: function(ast) {
function nop() {}
function checkExpression(node, appliedRules) {

8
src/compiler.js

@ -7,13 +7,13 @@ PEG.compiler = {
*/
compile: function(ast) {
var CHECK_NAMES = [
"missingReferencedRules",
"leftRecursion"
"reportMissingReferencedRules",
"reportLeftRecursion"
];
var PASS_NAMES = [
"proxyRules",
"stackDepths"
"removeProxyRules",
"computeStackDepths"
];
var i;

4
src/passes.js

@ -9,7 +9,7 @@ PEG.compiler.passes = {
/*
* Removes proxy rules -- that is, rules that only delegate to other rule.
*/
proxyRules: function(ast) {
removeProxyRules: function(ast) {
function isProxyRule(node) {
return node.type === "rule" && node.expression.type === "rule_ref";
}
@ -84,7 +84,7 @@ PEG.compiler.passes = {
* code generated by the emitter for the node will use. This information is
* used to declare varibles holding the stack data in the generated code.
*/
stackDepths: function(ast) {
computeStackDepths: function(ast) {
function computeZeroes(node) {
node.resultStackDepth = 0;
node.posStackDepth = 0;

4
test/checks-test.js

@ -7,7 +7,7 @@ test("reports missing referenced rules", function() {
raises(
function() {
var ast = PEG.parser.parse(grammar);
PEG.compiler.checks.missingReferencedRules(ast);
PEG.compiler.checks.reportMissingReferencedRules(ast);
},
function(e) {
return e instanceof PEG.GrammarError
@ -39,7 +39,7 @@ test("reports left recursion", function() {
raises(
function() {
var ast = PEG.parser.parse(grammar);
PEG.compiler.checks.leftRecursion(ast);
PEG.compiler.checks.reportLeftRecursion(ast);
},
function(e) {
return e instanceof PEG.GrammarError

4
test/passes-test.js

@ -143,7 +143,7 @@ test("removes proxy rules", function() {
for (var i = 0; i < cases.length; i++) {
var ast = PEG.parser.parse(cases[i].grammar);
deepEqual(PEG.compiler.passes.proxyRules(ast), cases[i].ast);
deepEqual(PEG.compiler.passes.removeProxyRules(ast), cases[i].ast);
}
});
@ -231,7 +231,7 @@ test("computes stack depths", function() {
for (var i = 0; i < cases.length; i++) {
var ast = PEG.parser.parse(cases[i].grammar);
PEG.compiler.passes.stackDepths(ast);
PEG.compiler.passes.computeStackDepths(ast);
deepEqual(ast.rules["start"].resultStackDepth, cases[i].resultStackDepth);
deepEqual(ast.rules["start"].posStackDepth, cases[i].posStackDepth);

Loading…
Cancel
Save