2 isBuild: function(builds) {
3 return builds.split('|').indexOf(this.build) != -1;
6 parse: function(file, build) {
13 file = new Stream(file);
15 line = file.readLine();
16 trimmed = line.trim();
17 if (this.isStatement(trimmed)) {
18 this.handleStatement(this.parseStatement(trimmed), file);
21 this.output.push(line);
22 this.checkExtraComma();
26 return this.output.join('\n');
29 checkExtraComma: function() {
30 var output = this.output,
31 ln = output.length - 1,
33 trimmed = line.trim(),
36 if (trimmed[0] == '}') {
37 while (output[--ln].trim() == '') {
40 prevLine = output[ln];
41 if (prevLine.trim().slice( - 1) == ',') {
42 output[ln] = prevLine.slice(0, prevLine.lastIndexOf(','));
47 isStatement: function(line) {
48 return line.substr(0, 3) == '//[' && line.substr( - 1) == ']';
51 handleStatement: function(statement, file) {
52 switch (statement.type) {
55 this.handleIf(file, statement.condition);
59 this.handleElse(file);
64 parseStatement: function(statement) {
65 var parts = statement.substring(3, statement.length - 1).split(' ');
72 handleIf: function(file, condition) {
73 if (this.isBuild(condition)) {
74 var next = this.getNextStatement(file);
75 this.output.push(next.buffer);
76 this.toEndIf(file, next);
79 this.handleStatement(this.getNextStatement(file), file);
83 handleElse: function(file) {
84 var next = this.toEndIf(file);
85 this.output.push(next.buffer);
88 toEndIf: function(file, next) {
89 next = next || this.getNextStatement(file);
90 while (next && next.type != 'endif') {
91 next = this.getNextStatement(file);
96 getNextStatement: function(file) {
103 line = file.readLine();
104 trimmed = line.trim();
105 if (!this.isStatement(trimmed)) {
109 ret = this.parseStatement(trimmed);
110 ret.buffer = buffer.join('\n');