Browse Source

Rename the |action| property of action AST nodes to |code|

redux
David Majda 12 years ago
parent
commit
718bcf5f87
  1. 4
      lib/compiler.js
  2. 4
      lib/metagrammar.js
  3. 4
      lib/metagrammar.pegjs
  4. 4
      test/metagrammar-test.js

4
lib/compiler.js

@ -743,12 +743,12 @@ PEG.Compiler = {
return PEG.Compiler.formatCode(
"${expressionCode}",
"var ${resultVar} = ${expressionResultVar} !== null",
" ? (function(${formalParams}) {${action}})(${actualParams})",
" ? (function(${formalParams}) {${actionCode}})(${actualParams})",
" : null;",
{
expressionCode: PEG.Compiler.compileNode(node.expression, expressionResultVar),
expressionResultVar: expressionResultVar,
action: node.action,
actionCode: node.code,
formalParams: formalParams.join(", "),
actualParams: actualParams.join(", "),
resultVar: resultVar

4
lib/metagrammar.js

@ -298,7 +298,7 @@ PEG.grammarParser = (function(){
pos = savedPos4;
}
var result26 = result27 !== null
? (function(elements, action) {
? (function(elements, code) {
var expression = elements.length != 1
? {
type: "sequence",
@ -308,7 +308,7 @@ PEG.grammarParser = (function(){
return {
type: "action",
expression: expression,
action: action
code: code
};
})(result27[0], result27[1])
: null;

4
lib/metagrammar.pegjs

@ -35,7 +35,7 @@ choice
}
sequence
= elements:labeled* action:action {
= elements:labeled* code:action {
var expression = elements.length != 1
? {
type: "sequence",
@ -45,7 +45,7 @@ sequence
return {
type: "action",
expression: expression,
action: action
code: code
};
}
/ elements:labeled* {

4
test/metagrammar-test.js

@ -67,11 +67,11 @@ var optional = nodeWithExpressionConstructor("optional");
var zeroOrMore = nodeWithExpressionConstructor("zero_or_more");
var oneOrMore = nodeWithExpressionConstructor("one_or_more");
function action(expression, action) {
function action(expression, code) {
return {
type: "action",
expression: expression,
action: action
code: code
};
};

Loading…
Cancel
Save