Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ione(ast.PatternObject,
wrap("{", list0(ps.Separator, PatternObjectPair), "}"));
var PatternArrayStrict =
ione(ast.PatternArray,
wrap("[", list0(ps.Separator, Pattern), "]"));
var BareSlurp =
ione(ast.PatternSimple,
ione(ast.Identifier, P.of("_")));
var PatternArraySlurpy =
iseq(ast.PatternArraySlurpy,
wrap(
"[",
P.seq(
Pattern.skip(ps.Separator).many(),
word("...").then(Pattern.or(BareSlurp))
),
"]"
));
var PatternArray =
P.alt(
PatternArrayStrict,
PatternArraySlurpy
);
return Pattern;
}
)
.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,
r.lengthSpec.atMost(1).map(data => !data.length ? '' : data[0])
)
.tie(),
Pa
.seq(
r.DECIMAL,
Pa
.alt(
Subscript: () =>
Parsimmon.seq(
Parsimmon.regexp(/_\s*/),
Parsimmon.alt(
Parsimmon.regexp(/{[a-zA-Z0-9+-]+}/),
Parsimmon.regexp(/[a-zA-Z0-9+-]/)
)
).map(([a, b]) => a + b),
module.exports = function(ps) {
var emptyPattern =
ione(ast.PatternSimple,
ione(ast.Identifier, P.of("_")));
var NormalClause =
P.seq(
keyword("case").then(_).then(ps.MatchPattern),
_.then(keyword("then").then(_)).then(ps.Block)
);
var ElseClause =
P.seq(
emptyPattern,
_.then(keyword("else").then(_)).then(ps.Block)
);
var MatchClause =
iseq(ast.MatchClause, NormalClause.or(ElseClause));
return iseq(ast.Match,
P.seq(
keyword("match").then(_).then(ps.BinExpr),
_.then(MatchClause).atLeast(1)
.skip(_)
.skip(keyword("end"))
));
};
.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()
.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
module.exports = function(ps) {
var OptionalName = ps.Identifier.or(P.of(null));
return iseq(ast.Function,
P.seq(
keyword("fn").then(_).then(OptionalName).skip(_),
wrap("(", ps.Parameters, ")").skip(_),
ps.Expr
));
};
const parser = options => r => Pa
.seq(
r.addSubExpr,
Pa
.seq(
Pa.optWhitespace,
Pa.alt(Pa.string('<<'), Pa.string('>>')),
Pa.optWhitespace,
r.addSubExpr
)
.map(data => ({ operand: data[3], operator: data[1] }))
.many()
)
.map(binaryOpMapper);
P.lazy((): mixed => {
const OperatorParser_ = OperatorParser.node('primitive')
return P.seq(
OperandParser,
P.seq(crap.then(OperatorParser_), crap.then(OperandParser)).many()
)
.map(
(value: [NodeType, Array]): NodeType =>
value[1].length > 0
? {
name: 'binaryOperation',
value: value[1].reduce(
(a: Array, b: NodeType): Array =>
a.concat(b),
[value[0]]
)
}
: value[0]
)
.desc(description)
})
STRING_SQ (r) {
return Pa
.seq(
Pa.string("'"),
Pa.alt(r.SCHAR, Pa.string('"'), r.ESCAPED_SQ, r.ESCAPED_ESCAPE_CHAR).many().tie(),
Pa.string("'")
)
.tie();
},
module.exports = function(ps) {
var ElseIf = iseq(ast.ElseIf,
P.seq(
keyword("elseif").then(_).then(ps.Expr).skip(_),
keyword("then").then(_).then(ps.Block).skip(_)
));
return iseq(ast.If,
P.seq(
keyword("if").then(_).then(ps.Expr).skip(_),
keyword("then").then(_).then(ps.Block).skip(_),
ElseIf.many(),
keyword("else").then(_).then(ps.Block).skip(_)
.skip(keyword("end"))
));
};