Skip to content

Instantly share code, notes, and snippets.

@sfpgmr sfpgmr/for.pegjs
Last active Nov 16, 2018

Embed
What would you like to do?
/ ForToken __
"(" & __
init:(ExpressionNoIn __ )? ";" __
test:(Expression __)? ";" __
update:(Expression __)?
")" __
body:Statement
{
/*scope.pop();*/
return {
nodeType: "ForStatement",
init: extractOptional(init, 0),
test: extractOptional(test, 0),
update: extractOptional(update, 0),
body: body
};
}
/ ForToken __
"(" & __
declarations:VariableDecl __ ";" __
test:(Expression __)? ";" __
update:(Expression __)?
")" __
body:Statement
{
/*scope.pop();*/
return {
nodeType: "ForStatement",
init: {
nodeType: "VariableDeclaration",
declarations: declarations,
kind: "var"
},
test: extractOptional(test, 0),
update: extractOptional(update, 0),
body: body
};
}
/ ForToken __
"(" __
left:LeftHandSideExpression __
InToken __
right:Expression __
")" __
body:Statement
{
/*scope.pop();*/
return {
nodeType: "ForInStatement",
left: left,
right: right,
body: body
};
}
/ ForToken __
"(" __
declarations:VariableDecl __
InToken __
right:Expression __
")" __
body:Statement
{
/*scope.pop();*/
return {
nodeType: "ForInStatement",
left: {
nodeType: "VariableDeclaration",
declarations: declarations,
kind: "var"
},
right: right,
body: body
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.