@fink/larix
Version:
A parser for generating fink's AST.
42 lines (39 loc) • 1.12 kB
JavaScript
import { add_operator, add_separator } from "@fink/prattler/expressions.js";
import { prefix, terminator } from "../expressions.js";
import { terminated_block } from "../block/init.js";
import { maybe_call_expr } from "../call/expr.js";
export 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);
}
}
}
});
export 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);
};