Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
},{}],6:[function(require,module,exports){
'use strict';
var Parsimmon = require('parsimmon');
/********************************************************************************************
ALIASES
********************************************************************************************/
var seq = Parsimmon.seq;
var alt = Parsimmon.alt;
var regex = Parsimmon.regex;
var string = Parsimmon.string;
var optWhitespace = Parsimmon.optWhitespace;
var whitespace = Parsimmon.whitespace;
var lazy = Parsimmon.lazy;
/********************************************************************************************
COMMON PATTERNS
********************************************************************************************/
// Make a parser optionnal
// "empty" parameter will be returned as result if the optionnal parser can't match
function opt(parser, empty) {
if (typeof empty == 'undefined') return parser.or(Parsimmon.succeed([]));
return parser.or(Parsimmon.succeed(empty));
}
// Join results of a parser
'use strict';
var Parsimmon = require('parsimmon');
/********************************************************************************************
ALIASES
********************************************************************************************/
var seq = Parsimmon.seq;
var alt = Parsimmon.alt;
var regex = Parsimmon.regex;
var string = Parsimmon.string;
var optWhitespace = Parsimmon.optWhitespace;
var whitespace = Parsimmon.whitespace;
var lazy = Parsimmon.lazy;
/********************************************************************************************
COMMON PATTERNS
********************************************************************************************/
// Make a parser optionnal
// "empty" parameter will be returned as result if the optionnal parser can't match
function opt(parser, empty) {
if (typeof empty == 'undefined') return parser.or(Parsimmon.succeed([]));
return parser.or(Parsimmon.succeed(empty));
}
// Join results of a parser
const parser = options => r => Pa
.seq(
r.CAST,
Pa.string('('),
Pa.optWhitespace,
r.expr.map(data => data.output),
Pa.whitespace,
r.AS,
Pa.whitespace,
r.castType,
Pa.optWhitespace,
Pa.string(')')
)
.map(data => {
const operator = new Operator();
operator.setName(data[0]);
operator.addParam(data[3]);
operator.addParam(data[7]);
const expr = new Expr();
expr.setType(Expr.Type.OPERATOR);
expr.setOperator(operator);
return expr;
});
Pa
.seq(
Pa.whitespace,
r.INTEGER
)
.tie()
.atMost(1)
.map(data => !data.length ? '' : data[0])
)
.tie(),
Pa
.seq(
r.UNSIGNED,
Pa
.seq(
Pa.whitespace,
r.INTEGER
)
.tie()
.atMost(1)
.map(data => !data.length ? '' : data[0])
)
.tie(),
Pa
.seq(
r.CHAR,
r.lengthSpec.atMost(1).map(data => !data.length ? '' : data[0])
)
.tie(),
Pa
.seq(
r.BINARY,
const parser = options => r => Pa
.seq(
r.expr
.map(data => data),
Pa
.seq(Pa.whitespace, r.AS, Pa.whitespace, r.ident)
.map(data => data[3])
.atMost(1)
.map(data => data[0])
)
.map(data => {
const projection = new Crud.Projection();
projection.setSource(data[0].output);
if (data[1]) {
projection.setAlias(data[1]);
} else {
projection.setAlias(data[0].input);
}
return { input: options.input, output: projection };
});
const parser = options => r => Pa
.seq(
r.andExpr,
Pa
.seq(Pa.whitespace, r.OR, Pa.whitespace, r.andExpr)
.map(data => ({ operand: data[3], operator: data[1] }))
.many()
)
.map(binaryOpMapper);
const parser = options => r => Pa
.seq(
r.expr
.map(data => data.output),
Pa
.seq(Pa.whitespace, Pa.alt(r.ASC, r.DESC))
.map(data => data[1])
.atMost(1)
.map(data => data[0])
)
.map(data => {
const order = new Crud.Order();
order.setExpr(data[0]);
if (data[1]) {
order.setDirection(data[1]);
}
return { input: options.input, output: order };
});
const parser = options => r => Pa
.alt(
Pa
.seq(
r.SIGNED,
Pa
.seq(
Pa.whitespace,
r.INTEGER
)
.tie()
.atMost(1)
.map(data => !data.length ? '' : data[0])
)
.tie(),
Pa
.seq(
r.UNSIGNED,
Pa
.seq(
Pa.whitespace,
r.INTEGER
)
.tie()