UNPKG

@fink/larix

Version:

A parser for generating fink's AST.

21 lines 515 B
import { curr_value, curr_loc } from "@fink/prattler/parser.js"; import { add_literal, non_binding } from "@fink/prattler/expressions.js"; export const number = ctx => { const { start, end } = curr_loc(ctx); const value = curr_value(ctx); return [{ type: `number`, value, loc: { start, end } }, ctx]; }; export const num = token_type => ({ ...non_binding(token_type), nud: () => ctx => number(ctx) }); export const add_number = ctx => add_literal(num(`number`))(ctx);