Skip to content
Permalink
Browse files

tweak node generation

  • Loading branch information
lahmatiy committed Mar 21, 2017
1 parent ed90fc1 commit 1e9587710efa8e9338bcf0bc794b4b45f286231d
@@ -152,25 +152,26 @@ module.exports = {
};
},
generate: function(node) {
var result = '';
var a = node.a !== null && node.a !== undefined;
var b = node.b !== null && node.b !== undefined;
var result;

if (a) {
result += node.a === '+1' || node.a === '1' ? 'n' :
node.a === '-1' ? '-n' :
node.a + 'n';
}

if (a && b) {
if (String(node.b).charAt(0) !== '-' &&
String(node.b).charAt(0) !== '+') {
result += '+';
result =
node.a === '+1' || node.a === '1' ? 'n' :
node.a === '-1' ? '-n' :
node.a + 'n';

if (b) {
b = String(node.b);
if (b.charAt(0) === '-' || b.charAt(0) === '+') {
result = [result, b.charAt(0), b.substr(1)];
} else {
result = [result, '+', b];
}
}
}

if (b) {
result += node.b;
} else {
result = String(node.b);
}

return result;
@@ -151,7 +151,7 @@ module.exports = {
}

if (node.flags !== null) {
result.push(flagsPrefix + node.flags);
result.push(flagsPrefix, node.flags);
}

result.push(']');
@@ -33,7 +33,7 @@ module.exports = {
};
},
generate: function(node) {
return [].concat(node.name, '(', this.each(node.children), ')');
return [].concat(node.name + '(', this.each(node.children), ')');
},
walkContext: 'function'
};
@@ -63,7 +63,7 @@ module.exports = {
},
generate: function(node) {
return node.value !== null
? ['(' + node.name + ':', this.generate(node.value), ')']
: '(' + node.name + ')';
? ['(', node.name, ':', this.generate(node.value), ')']
: ['(', node.name, ')'];
}
};
@@ -50,6 +50,6 @@ module.exports = {
};
},
generate: function(node) {
return node.left + '/' + node.right;
return [node.left, '/', node.right];
}
};

0 comments on commit 1e95877

Please sign in to comment.
You can’t perform that action at this time.