@fink/larix
Version:
A parser for generating fink's AST.
19 lines • 630 B
JavaScript
import { non_binding, add_operator } from "@fink/prattler/expressions.js";
import { curr_loc, curr_value } from "@fink/prattler/parser.js";
import { maybe_call_expr } from "../call/expr.js";
export const partial = (token_type, expr_type) => ({ ...non_binding(token_type),
nud: () => ctx => {
const loc = curr_loc(ctx);
const op = curr_value(ctx);
const expr = {
type: expr_type,
value: op,
loc
};
return maybe_call_expr(expr, ctx);
}
});
export const add_partial = ctx => {
let ˆpipe_result_1 = ctx;
return ˆpipe_result_1 = add_operator(partial(`?`, `partial`))(ˆpipe_result_1);
};