Repository navigation
graphql_parser: drop the re dependency - #222
Open
cuihtlauac wants to merge 1 commit into
Open
cuihtlauac wants to merge 1 commit into
cuihtlauac wants to merge 1 commit into
Conversation
`re` was pulled into `graphql_parser` only for a handful of single-character/newline operations, forcing a full regex engine onto every downstream package. - `block_string.ml`: replace `Re.split` (split on \r\n, \n, \r) with a hand-rolled `split_lines` that scans the string directly, mirroring the existing `get_block_string_indentation` logic. - `ast.ml`: replace the chain of `Re.replace_string` calls in `quote_string` with a single-pass buffer escape. - Drop `re` from `graphql_parser/src/dune` and `graphql_parser.opam`. Closes andreas#221 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Author
|
Heads-up: the red ocaml-ci checks on this PR are pre-existing and unrelated to this change —
This PR only touches |
Author
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
graphql_parserpulled inre— a full regex engine — only for a handful of single-character and newline operations. Sincereis a hard dependency, every downstream package (graphql,graphql-lwt, …) inherited it transitively. This removes it entirely.Fixes #221.
Changes
block_string.ml: replace theRe.spliton\r\n/\n/\rindedent_block_string_valuewith a hand-rolledsplit_linesthat scans the string directly, mirroring the newline handling already present inget_block_string_indentation.ast.ml: replace the chain ofRe.replace_stringcalls inquote_string(escaping\,",\b,\f,\n,\r,\t) with a single-passBufferescape.refromgraphql_parser/src/duneandgraphql_parser.opam.Notes
The issue only mentioned the
Re.splitsite, butast.mlalso usedRefor pretty-printing escapes; both are replaced so the dependency can actually be dropped.split_linespreserves empty lines (including interior ones), which the existing block-string tests rely on. The single-pass escape is equivalent to the previous sequential replacements.Testing
dune runtest graphql_parserpasses (all 7 parser tests, includingblock stringandescaped string).graphqlandgraphql-lwtbuild cleanly against the updated parser.🤖 Generated with Claude Code