INNER CODE UNIT · JavaScript
reduceParenthesis
NerdLang/nerd · lib/parser.js:85
var reduceParenthesis = function(_ast)
{
for(var i = 0; i < _ast.length; i++)
{
if(_ast[i-1] && _ast[i-1] == "IF" && _ast[i] == "(" && _ast[i+1] && _ast[i+1] == "(")
{
if(_ast[i+3] && _ast[i+3] == ")")
{
_ast = _ast.slice(0,2).concat([_ast[i+2]]).concat(_ast.slice(5));
reduceParenthesis(_ast);
}
}
else if( (!_ast[i-1] || (_ast[i-1] && noReduceParenthesis.indexOf(_ast[i-1]) < 0) ) && _ast[i] == "(" && _ast[i+2] && _ast[i+2] == ")" )
{
_ast = _ast.slice(0,i).concat([_ast[i+1]]).concat(_ast.slice(i+3));
reduceParenthesis(_ast);
}
}