@fink/larix
Version:
A parser for generating fink's AST.
61 lines (51 loc) • 1.2 kB
JavaScript
const {
add_operator,
add_separator
} = require("@fink/prattler/expressions.js");
const {
prefix,
terminator
} = require("../expressions.js");
const {
terminated_block
} = require("../block/init.js");
const {
maybe_call_expr
} = require("../call/expr.js");
const group = token_type => ({ ...prefix(token_type),
nud: () => ({
group_call,
...ctx
}) => {
const [{
exprs,
comments,
loc
}, next_ctx] = terminated_block(ctx, `)`);
const expr = {
type: `group`,
exprs,
comments,
loc
};
{
const ˆvalue_1 = true;
// TODO: why is jsx getting lost in terminated block
/* istanbul ignore else */
if (ˆvalue_1 === (ctx.jsx || group_call === false)) {
return [expr, next_ctx];
}
{
return maybe_call_expr(expr, next_ctx);
}
}
}
});
exports.group = group;
const add_group = ctx => {
let ˆpipe_result_3 = ctx;
ˆpipe_result_3 = add_operator(group(`(`))(ˆpipe_result_3);
ˆpipe_result_3 = add_separator(terminator(`,`))(ˆpipe_result_3);
return ˆpipe_result_3 = add_separator(terminator(`)`))(ˆpipe_result_3);
};
exports.add_group = add_group;