Skip to content

Commit

Permalink
fix for statement empty test and update
Browse files Browse the repository at this point in the history
  • Loading branch information
w-y committed May 23, 2017
1 parent 6f49124 commit 7d13e3a
Show file tree
Hide file tree
Showing 3 changed files with 172 additions and 42 deletions.
3 changes: 1 addition & 2 deletions mock/statement.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ for (var i = 100, j = 0; i >= 0; --i) {

}

for (var i = 0; ; ) {
for (var i = 0; ;) {

}

Expand All @@ -61,7 +61,6 @@ for (var i = 0; ; i) {

}


for (i in [1,2,3]) {

}
Expand Down
52 changes: 52 additions & 0 deletions src/bnf/IterationStatement.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ module.exports = {
'for LeftParenthesis ; ; Expression_In RightParenthesis Statement',
'for LeftParenthesis ; ; RightParenthesis Statement',
'for LeftParenthesis ; Expression_In ; RightParenthesis Statement',

'for LeftParenthesis VAR VariableDeclarationList ; ; Expression_In RightParenthesis Statement',
'for LeftParenthesis VAR VariableDeclarationList ; Expression_In ; RightParenthesis Statement',
'for LeftParenthesis VAR VariableDeclarationList ; ; RightParenthesis Statement',
'for LeftParenthesis LexicalDeclaration ; Expression_In RightParenthesis Statement',
'for LeftParenthesis LexicalDeclaration Expression_In ; RightParenthesis Statement',
'for LeftParenthesis LexicalDeclaration ; RightParenthesis Statement',
],
handlers: [
'$$ = new (require(\'./ast/IterationStatement\').DoWhileStatementNode)($5, $2, { loc: this._$, yy })',
Expand Down Expand Up @@ -115,6 +122,51 @@ module.exports = {
require('./ast/IterationStatement').checkForAutoSemicolonInsertion(yy.autoInsertionOffset, $2.range, $6.range, yy.lexer.yylloc);
$$ = new (require('./ast/IterationStatement').ForStatementNode)(null, $4, null, $7, { loc: this._$, yy })
`,
`
require('./ast/IterationStatement').checkForAutoSemicolonInsertion(yy.autoInsertionOffset, $2.range, $8.range, yy.lexer.yylloc);
$$ = new (require('./ast/IterationStatement').ForStatementNode)(
new (require('./ast/VariableStatement').VariableStatementNode)($4, { loc: {
first_line: $3.first_line,
last_line: $4[$4.length-1].lastLine,
first_column: $3.firts_column,
last_column: $4[$4.length-1].lastColumnu,
range: [$3.range[0], $4[$4.length-1].range[1]],
}, yy }), null, $7, $9, { loc: this._$, yy });
`,
`
require('./ast/IterationStatement').checkForAutoSemicolonInsertion(yy.autoInsertionOffset, $2.range, $8.range, yy.lexer.yylloc);
$$ = new (require('./ast/IterationStatement').ForStatementNode)(
new (require('./ast/VariableStatement').VariableStatementNode)($4, { loc: {
first_line: $3.first_line,
last_line: $4[$4.length-1].lastLine,
first_column: $3.firts_column,
last_column: $4[$4.length-1].lastColumnu,
range: [$3.range[0], $4[$4.length-1].range[1]],
}, yy }), $6, null, $9, { loc: this._$, yy });
`,
`
require('./ast/IterationStatement').checkForAutoSemicolonInsertion(yy.autoInsertionOffset, $2.range, $7.range, yy.lexer.yylloc);
$$ = new (require('./ast/IterationStatement').ForStatementNode)(
new (require('./ast/VariableStatement').VariableStatementNode)($4, { loc: {
first_line: $3.first_line,
last_line: $4[$4.length-1].lastLine,
first_column: $3.firts_column,
last_column: $4[$4.length-1].lastColumnu,
range: [$3.range[0], $4[$4.length-1].range[1]],
}, yy }), null, null, $8, { loc: this._$, yy });
`,
`
require('./ast/IterationStatement').checkForAutoSemicolonInsertion(yy.autoInsertionOffset, $2.range, $6.range, yy.lexer.yylloc);
$$ = new (require('./ast/IterationStatement').ForStatementNode)($3, null, $5, $7, { loc: this._$, yy })
`,
`
require('./ast/IterationStatement').checkForAutoSemicolonInsertion(yy.autoInsertionOffset, $2.range, $6.range, yy.lexer.yylloc);
$$ = new (require('./ast/IterationStatement').ForStatementNode)($3, $4, null, $7, { loc: this._$, yy })
`,
`
require('./ast/IterationStatement').checkForAutoSemicolonInsertion(yy.autoInsertionOffset, $2.range, $5.range, yy.lexer.yylloc);
$$ = new (require('./ast/IterationStatement').ForStatementNode)($3, null, null, $6, { loc: this._$, yy })
`,
],
subRules: [
require('./Expression_In'),
Expand Down
159 changes: 119 additions & 40 deletions src/parser.js

Large diffs are not rendered by default.

0 comments on commit 7d13e3a

Please sign in to comment.