Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.chain((identifier: string): IdentifierNodeType => {
const exceptions = ['null', 'false', 'true', 'if', 'each']
if (exceptions.indexOf(identifier) < 0) {
return P.of(identifier)
} else {
return P.fail(`identifier but got keyword ${identifier}`)
}
})
.map((value: string): IdentifierNodeType => ({
function checkBlock(statements) {
var n = statements.length;
var i = n - 1;
var last = statements[i];
if (last.type !== "ExprStmt") {
return P.fail("blocks must end with an expression");
} else {
return P.of([statements.slice(0, i), last]);
}
}
return NameParser.chain(function(x) {
if (x === kw) {
return P.of(kw);
} else {
return P.fail(kw);
}
});
}
return this.operator.chain((op) => {
const info = this.leftMap.get(op)
if (info) {
if (info.precedence < precedence) {
return P.fail('Precedence below minimum expected')
}
return info.leftDenotation.call(this, info, lhs).chain((lhs2) => {
return this.parseLeftDenotation(precedence, lhs2)
})
}
return P.fail('Unkown operator ' + op)
}).or(P.succeed(lhs))
}
function helper(id) {
if (keywords.indexOf(id) < 0) {
return P.of(id);
} else {
return P.fail("identifier but got keyword '" + id + "'");
}
}
return this.operator.chain((op) => {
const info = this.leftMap.get(op)
if (info) {
if (info.precedence < precedence) {
return P.fail('Precedence below minimum expected')
}
return info.leftDenotation.call(this, info, lhs).chain((lhs2) => {
return this.parseLeftDenotation(precedence, lhs2)
})
}
return P.fail('Unkown operator ' + op)
}).or(P.succeed(lhs))
}