Skip to content

Consider replacing nom with hand-written parsing rules for XPath #39602

@simonwuelker

Description

@simonwuelker

I'm not a big fan of nom because it is hard to debug and causes extremely cryptic compiler errors.

But the bigger problem is that noms parsing model relies on repeatedly trying parser functions and seeing if they succeed. That means that input is potentially parsed multiple times before the correct approach is found, and that is fundamentally incompatible with #39596. We would have to use something like a seperate pass over the Expr AST so prefixes are only resolved once. I'd prefer not to.

The parser in gecko (https://searchfox.org/firefox-main/source/dom/xslt/xpath/txExprLexer.cpp, https://searchfox.org/firefox-main/source/dom/xslt/xpath/txExprParser.cpp) does not look that bad.

nom is only used in two places, xpath and cookie, so it would be fairly easy to get rid of.

Metadata

Metadata

Assignees

Labels

A-dependenciesPull requests that update a dependency fileI-refactorNo impact; the issue is one of maintainability or tidiness. Proposed solution requires refactoring.

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions