Skip to content

Commit feb5c6d

Browse files
committed
Put maybe-action transform in the parser actions, not the Action constructor
1 parent ca4041d commit feb5c6d

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

src/ast/action.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
'use strict';
22

3-
var util = require('../util');
4-
var Maybe = require('./maybe');
3+
var util = require('../util');
54

65
var Action = function(expression, actionName) {
7-
if (expression instanceof Maybe)
8-
return new Maybe(new Action(expression._expression, actionName));
9-
106
this._expression = expression;
117
this._actionName = actionName;
128
};

src/compiler.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ var actions = {
4747
},
4848

4949
action: function(text, a, b, elements) {
50-
return new Action(elements[0], elements[2].id.text);
50+
var actionName = elements[2].id.text;
51+
52+
if (elements[0] instanceof Maybe)
53+
return new Maybe(new Action(elements[0]._expression, actionName));
54+
else
55+
return new Action(elements[0], actionName);
5156
},
5257

5358
sequence: function(text, a, b, elements) {

0 commit comments

Comments
 (0)