UNPKG

@fink/larix

Version:

A parser for generating fink's AST.

43 lines (35 loc) 809 B
const { curr_value, curr_loc } = require("@fink/prattler/parser.js"); const { add_identifier, non_binding } = require("@fink/prattler/expressions.js"); const { maybe_call_expr } = require("../call/expr.js"); const identifier = ctx => { const value = curr_value(ctx); const loc = curr_loc(ctx); return [{ type: `ident`, value, loc: { ...loc, identifierName: value } }, ctx]; }; exports.identifier = identifier; const ident = op => ({ ...non_binding(op), nud: () => ctx => { const [expr, next_ctx] = identifier(ctx); return maybe_call_expr(expr, next_ctx); } }); exports.ident = ident; const add_ident = ctx => { let ˆpipe_result_1 = ctx; return ˆpipe_result_1 = add_identifier(ident(`ident`))(ˆpipe_result_1); }; exports.add_ident = add_ident;