literals need newlines after them
This commit is contained in:
parent
e2a205ab22
commit
8d5f800e2f
|
@ -8,6 +8,7 @@
|
|||
|
||||
exports.Lexer = Lexer = (function() {
|
||||
Lexer.name = 'Lexer';
|
||||
|
||||
function Lexer() {}
|
||||
|
||||
Lexer.prototype.tokenize = function(code, opts) {
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
exports.Base = Base = (function() {
|
||||
Base.name = 'Base';
|
||||
|
||||
function Base() {}
|
||||
|
||||
Base.prototype.compile = function(o, lvl) {
|
||||
|
@ -193,6 +194,7 @@
|
|||
|
||||
Block.name = 'Block';
|
||||
|
||||
|
||||
function Block(nodes) {
|
||||
this.expressions = compact(flatten(nodes || []));
|
||||
}
|
||||
|
@ -284,7 +286,11 @@
|
|||
} else if (top) {
|
||||
node.front = true;
|
||||
code = node.compile(o);
|
||||
codes.push(node.isStatement(o) ? code : "" + this.tab + code + ";");
|
||||
if (!node.isStatement(o)) {
|
||||
code = "" + this.tab + code + ";";
|
||||
if (node instanceof Literal) code = "" + code + "\n";
|
||||
}
|
||||
codes.push(code);
|
||||
} else {
|
||||
codes.push(node.compile(o, LEVEL_LIST));
|
||||
}
|
||||
|
@ -389,6 +395,7 @@
|
|||
|
||||
Literal.name = 'Literal';
|
||||
|
||||
|
||||
function Literal(value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
@ -447,6 +454,7 @@
|
|||
|
||||
Return.name = 'Return';
|
||||
|
||||
|
||||
function Return(expr) {
|
||||
if (expr && !expr.unwrap().isUndefined) this.expression = expr;
|
||||
}
|
||||
|
@ -483,6 +491,7 @@
|
|||
|
||||
Value.name = 'Value';
|
||||
|
||||
|
||||
function Value(base, props, tag) {
|
||||
if (!props && base instanceof Value) return base;
|
||||
this.base = base;
|
||||
|
@ -633,6 +642,7 @@
|
|||
|
||||
Comment.name = 'Comment';
|
||||
|
||||
|
||||
function Comment(comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
@ -658,6 +668,7 @@
|
|||
|
||||
Call.name = 'Call';
|
||||
|
||||
|
||||
function Call(variable, args, soak) {
|
||||
this.args = args != null ? args : [];
|
||||
this.soak = soak;
|
||||
|
@ -829,6 +840,7 @@
|
|||
|
||||
Extends.name = 'Extends';
|
||||
|
||||
|
||||
function Extends(child, parent) {
|
||||
this.child = child;
|
||||
this.parent = parent;
|
||||
|
@ -850,6 +862,7 @@
|
|||
|
||||
Access.name = 'Access';
|
||||
|
||||
|
||||
function Access(name, tag) {
|
||||
this.name = name;
|
||||
this.name.asKey = true;
|
||||
|
@ -880,6 +893,7 @@
|
|||
|
||||
Index.name = 'Index';
|
||||
|
||||
|
||||
function Index(index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
@ -904,6 +918,7 @@
|
|||
|
||||
Range.name = 'Range';
|
||||
|
||||
|
||||
Range.prototype.children = ['from', 'to'];
|
||||
|
||||
function Range(from, to, tag) {
|
||||
|
@ -989,6 +1004,7 @@
|
|||
|
||||
Slice.name = 'Slice';
|
||||
|
||||
|
||||
Slice.prototype.children = ['range'];
|
||||
|
||||
function Slice(range) {
|
||||
|
@ -1017,6 +1033,7 @@
|
|||
|
||||
Obj.name = 'Obj';
|
||||
|
||||
|
||||
function Obj(props, generated) {
|
||||
this.generated = generated != null ? generated : false;
|
||||
this.objects = this.properties = props || [];
|
||||
|
@ -1085,6 +1102,7 @@
|
|||
|
||||
Arr.name = 'Arr';
|
||||
|
||||
|
||||
function Arr(objs) {
|
||||
this.objects = objs || [];
|
||||
}
|
||||
|
@ -1135,6 +1153,7 @@
|
|||
|
||||
Class.name = 'Class';
|
||||
|
||||
|
||||
function Class(variable, parent, body) {
|
||||
this.variable = variable;
|
||||
this.parent = parent;
|
||||
|
@ -1294,6 +1313,7 @@
|
|||
|
||||
Assign.name = 'Assign';
|
||||
|
||||
|
||||
function Assign(variable, value, context, options) {
|
||||
this.variable = variable;
|
||||
this.value = value;
|
||||
|
@ -1494,6 +1514,7 @@
|
|||
|
||||
Code.name = 'Code';
|
||||
|
||||
|
||||
function Code(params, body, tag) {
|
||||
this.params = params || [];
|
||||
this.body = body || new Block;
|
||||
|
@ -1608,6 +1629,7 @@
|
|||
|
||||
Param.name = 'Param';
|
||||
|
||||
|
||||
function Param(name, value, splat) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
|
@ -1649,6 +1671,7 @@
|
|||
|
||||
Splat.name = 'Splat';
|
||||
|
||||
|
||||
Splat.prototype.children = ['name'];
|
||||
|
||||
Splat.prototype.isAssignable = YES;
|
||||
|
@ -1717,6 +1740,7 @@
|
|||
|
||||
While.name = 'While';
|
||||
|
||||
|
||||
function While(condition, options) {
|
||||
this.condition = (options != null ? options.invert : void 0) ? condition.invert() : condition;
|
||||
this.guard = options != null ? options.guard : void 0;
|
||||
|
@ -1792,6 +1816,7 @@
|
|||
|
||||
Op.name = 'Op';
|
||||
|
||||
|
||||
function Op(op, first, second, flip) {
|
||||
if (op === 'in') return new In(first, second);
|
||||
if (op === 'do') return this.generateDo(first);
|
||||
|
@ -1959,6 +1984,7 @@
|
|||
|
||||
In.name = 'In';
|
||||
|
||||
|
||||
function In(object, array) {
|
||||
this.object = object;
|
||||
this.array = array;
|
||||
|
@ -2033,6 +2059,7 @@
|
|||
|
||||
Try.name = 'Try';
|
||||
|
||||
|
||||
function Try(attempt, error, recovery, ensure) {
|
||||
this.attempt = attempt;
|
||||
this.error = error;
|
||||
|
@ -2075,6 +2102,7 @@
|
|||
|
||||
Throw.name = 'Throw';
|
||||
|
||||
|
||||
function Throw(expression) {
|
||||
this.expression = expression;
|
||||
}
|
||||
|
@ -2101,6 +2129,7 @@
|
|||
|
||||
Existence.name = 'Existence';
|
||||
|
||||
|
||||
function Existence(expression) {
|
||||
this.expression = expression;
|
||||
}
|
||||
|
@ -2136,6 +2165,7 @@
|
|||
|
||||
Parens.name = 'Parens';
|
||||
|
||||
|
||||
function Parens(body) {
|
||||
this.body = body;
|
||||
}
|
||||
|
@ -2176,6 +2206,7 @@
|
|||
|
||||
For.name = 'For';
|
||||
|
||||
|
||||
function For(body, source) {
|
||||
var _ref2;
|
||||
this.source = source.source, this.guard = source.guard, this.step = source.step, this.name = source.name, this.index = source.index;
|
||||
|
@ -2317,6 +2348,7 @@
|
|||
|
||||
Switch.name = 'Switch';
|
||||
|
||||
|
||||
function Switch(subject, cases, otherwise) {
|
||||
this.subject = subject;
|
||||
this.cases = cases;
|
||||
|
@ -2394,6 +2426,7 @@
|
|||
|
||||
If.name = 'If';
|
||||
|
||||
|
||||
function If(condition, body, options) {
|
||||
this.body = body;
|
||||
if (options == null) options = {};
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
exports.OptionParser = OptionParser = (function() {
|
||||
OptionParser.name = 'OptionParser';
|
||||
|
||||
function OptionParser(rules, banner) {
|
||||
this.banner = banner;
|
||||
this.rules = buildRules(rules);
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
exports.Rewriter = (function() {
|
||||
Rewriter.name = 'Rewriter';
|
||||
|
||||
function Rewriter() {}
|
||||
|
||||
Rewriter.prototype.rewrite = function(tokens) {
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
exports.Scope = Scope = (function() {
|
||||
Scope.name = 'Scope';
|
||||
|
||||
Scope.root = null;
|
||||
|
||||
function Scope(parent, expressions, method) {
|
||||
|
|
|
@ -227,7 +227,10 @@ exports.Block = class Block extends Base
|
|||
else if top
|
||||
node.front = true
|
||||
code = node.compile o
|
||||
codes.push if node.isStatement o then code else "#{@tab}#{code};"
|
||||
unless node.isStatement o
|
||||
code = "#{@tab}#{code};"
|
||||
code = "#{code}\n" if node instanceof Literal
|
||||
codes.push code
|
||||
else
|
||||
codes.push node.compile o, LEVEL_LIST
|
||||
if top
|
||||
|
|
Loading…
Reference in New Issue