-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathprogram.js
31 lines (27 loc) · 906 Bytes
/
program.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*jslint node: true, indent: 2 */
'use strict';
var doBody = require('./helper/body');
module.exports = function (node) {
if (!node.children || node.children.length === 0) {
return '';
}
var codegen = this.process.bind(this), str = '<?php' + this.nl;
if (node.children[0].kind === 'inline') {
str = '';
node.children[0].omitClosingTag = true;
}
// Is the last expression and an inline
if (node.children[node.children.length - 1].kind === 'inline') {
node.children[node.children.length - 1].isLast = true;
}
if (
!this.forceNamespaceBrackets &&
node.children.length === 1 &&
node.children[0].kind === 'namespace'
) {
return str + 'namespace ' + node.children[0].name + ';' +
this.nl + this.nl +
doBody.call(this, codegen, '', node.children[0].children, true);
}
return str + doBody.call(this, codegen, '', node.children, true);
};