mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
33 lines
648 B
JavaScript
33 lines
648 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;
|
|
}
|
|
|
|
this.body = codegen.generateCode(this.body);
|
|
return this;
|
|
}
|
|
|
|
writeCode(writer) {
|
|
var body = this.body;
|
|
writer.writeBlock(body);
|
|
writer.write('\n');
|
|
}
|
|
|
|
walk(walker) {
|
|
this.body = walker.walk(this.body);
|
|
}
|
|
}
|
|
|
|
module.exports = Else; |