UNPKG

@thi.ng/parse

Version:

Purely functional parser combinators & AST generation for generic inputs

19 lines (18 loc) 437 B
import { xform } from "../combinators/xform.js"; const xfHoist = (scope) => { Object.assign(scope, scope.children[0]); return scope; }; const xfHoistResult = (scope) => { scope.result = scope.children[0].result; scope.children = null; return scope; }; const hoist = (parser) => xform(parser, xfHoist); const hoistResult = (parser) => xform(parser, xfHoistResult); export { hoist, hoistResult, xfHoist, xfHoistResult };