Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rationalize/reuse parsers? #518

Open
jamescheney opened this issue Mar 1, 2019 · 0 comments
Open

Rationalize/reuse parsers? #518

jamescheney opened this issue Mar 1, 2019 · 0 comments

Comments

@jamescheney
Copy link
Contributor

#517 is a good idea but seems like an occasion to rethink/rationalize the various lexers/parsers we currently support (Links, json, XML).

The XML lexer/parser was added a while ago and is not used internally in Links but is exposed as a library function parseXml. I don't know if we have any active use cases where we need this.

@SimonJF has a use case for an HTML parser (i.e. to handle auto-closed tags and non-quoted attributes), which is currently implemented in plain Links using parser combinators, and is probably a lot slower than an ocamllex/yacc parser would be. We could in principle do the same thing to parse plain XML.

The JSON lexer/parser exists to allow parsing JSON messages but is not accessible from Links. Might it be useful to support a parseJson library function - especially if we also were to support sending RPC-calls to other REST-style services (or serving such calls from Links)?

Alternatively, if we want to support efficient parsing of all three either internally or exposed as Links library functions, I can also imagine that there might be standard JSON, XML or HTML parsing libraries available for OCaml that we could simply reuse here. From a quick google of OPAM, yojson appears to support JSON parsing and markup appears to support HTML and XML parsing, and we already depend on both libraries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant