S-expressions: Difference between revisions
m
→JavaScript :: Functional: Some reduction and tidying.
m (→JavaScript :: Functional: Some reduction and tidying.) |
|||
Line 3,792:
// A tuple of (parsed trees, residual tokens)
// derived from a list of tokens.
until(finished)(readToken)([
]);
// finished :: ([Expr], [String]) -> Bool
const finished = ([,
// closes a sub-expression.
// readToken :: ([Expr], [String]) -> ([Expr], [String])
const readToken = ([
// depleted
const [token, ...ts] = tokens;
// a sub-expression to
return "(" === token ? (() =>
const [expr,
) : ")" === t ? (▼
) : Tuple(▼
exprs.concat(atom(t))▼
return [xs.concat([expr]), rest.slice(1)];▼
// ------------------- ATOM PARSER -------------------
Line 3,883 ⟶ 3,880:
// --------------------- GENERIC ---------------------
▲ });
// even :: Int -> Bool
Line 3,922 ⟶ 3,894:
f => {
const go = x =>
p(x) ? x : go(f(x));
return go;
};
▲ 0 < xs.length ? (
▲ xs.slice(1)
return main();
|