marko/compiler/ast/Else.js
2015-12-28 21:55:29 -07:00

25 lines
510 B
JavaScript

'use strict';
var Node = require('./Node');
class Else extends Node {
constructor(def) {
super('Else');
this.body = this.makeContainer(def.body);
this.matched = false;
}
generateCode(codegen) {
if (!this.matched) {
codegen.addError('Unmatched else statement');
return;
}
var body = this.body;
codegen.write('else ');
codegen.generateBlock(body);
codegen.write('\n');
}
}
module.exports = Else;