UNPKG

@fink/larix

Version:

A parser for generating fink's AST.

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