UNPKG

@fink/larix

Version:

A parser for generating fink's AST.

35 lines (29 loc) 709 B
const { non_binding, add_operator } = require("@fink/prattler/expressions.js"); const { curr_loc, curr_value } = require("@fink/prattler/parser.js"); const { maybe_call_expr } = require("../call/expr.js"); 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); } }); exports.partial = partial; const add_partial = ctx => { let ˆpipe_result_1 = ctx; return ˆpipe_result_1 = add_operator(partial(`?`, `partial`))(ˆpipe_result_1); }; exports.add_partial = add_partial;