Skip to content

Commit 64a9478

Browse files
committed
avoid nested arrays - the rule is : any node must have it's type at offset 0
1 parent 86a2f05 commit 64a9478

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/parser/statement.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@ module.exports = function(api, tokens, EOF) {
1414
read_top_statements: function() {
1515
var result = [];
1616
while(this.token !== EOF && this.token !== '}') {
17-
result.push(this.read_top_statement());
17+
var statement = this.read_top_statement();
18+
if (statement) {
19+
if (typeof statement[0] === 'string') {
20+
result.push(statement);
21+
} else {
22+
result = result.concat(statement);
23+
}
24+
}
1825
}
1926
return result;
2027
}
@@ -71,7 +78,14 @@ module.exports = function(api, tokens, EOF) {
7178
,read_inner_statements: function() {
7279
var result = [];
7380
while(this.token != EOF && this.token !== '}') {
74-
result.push(this.read_inner_statement());
81+
var statement = this.read_inner_statement();
82+
if (statement) {
83+
if (typeof statement[0] === 'string') {
84+
result.push(statement);
85+
} else {
86+
result = result.concat(statement);
87+
}
88+
}
7589
}
7690
return result;
7791
}

0 commit comments

Comments
 (0)