TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

A parser-combinator approach to parsing JSON

32 点作者 hko将近 16 年前

2 条评论

aufreak2将近 16 年前
It looks like modeling your parser as fn(str) -&#62; (list-of (pair-of value remaining-str)) might work out as a more compact (in terms of code) and powerful representation. I did something similar when writing a combinator library for querying xml-like trees and it ended up quite powerful. (you can replace "str" with any sequence type).<p>For one thing, you can write parsers that return more than one value - i.e. parsers that are ambiguous about how they parse the string they are given. That lets you express "longest" and "shortest" as parser combinators rather than some special operation for each parser.
评论 #665898 未加载
评论 #666079 未加载
aufreak2将近 16 年前
A well documented effort, definitely!