Add basic support for named pattern#1
Closed
hhugo wants to merge 24 commits into
Closed
Conversation
This was referenced Feb 8, 2026
14d80de to
b0c1d9e
Compare
Add two example calculators showing how to bridge Sedlexing.lexbuf with ocamlyacc/menhir parsers, and document the pattern in the README. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The upper bound of the surrogate rejection range was 0xdf00 instead of 0xdfff, which would have allowed U+DF01..U+DFFF through. In practice the bug was masked by the local Uchar.of_int wrapper, but fix it for correctness. Add comments explaining why only check_three needs the surrogate check, and add an expect test for surrogate rejection. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…nity#176) * Support nested let..in for [%sedlex.regexp?] definitions (ocaml-community#41) Allow users to define named regexps using nested let statements, e.g.: let int_lit = let digit = [%sedlex.regexp? '0'..'9'] in [%sedlex.regexp? Plus digit] Add eval_regexp_expr method that recursively evaluates let..in chains of regexp definitions, used by both the expression handler and structure_with_regexps. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Add comment to ast match * Update documentation --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
The default branch in a match%sedlex is not a regexp — it fires when no rule matches, so zero characters are consumed and the lexeme is "". To catch unexpected characters, use `any` instead. Closes ocaml-community#51 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…-community#181) * Document regexp operator precedence (fixes ocaml-community#35) Since sedlex regexps are OCaml patterns, they follow OCaml's pattern precedence: | (lowest) < , < constructor application (highest). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Doc: add new sub sections * cleanup * cleanup --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
- Add ppx_sedlex.mli with minimal public surface - Replace table_counter/partition_counter refs with Hashtbl.length - Expose reset_state instead of raw partitions/tables hashtables - Bake builtin_regexps and Fun.id into handle_sedlex_match - Comment out unused extensions value - Remove StringMap, builtin_regexps, regexp_of_pattern from interface Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
e7ac0a6 to
79f3579
Compare
Add [%compile_error] test extension that applies the sedlex mapper to an expression, catches errors, and prints them with OCaml's caret display (line numbers stripped for stability). Expose map_expression in ppx_sedlex for this purpose. 27 expect tests in test/codegen/test_errors.ml covering every error path in ppx_sedlex.ml: as-binding restrictions, operator misuse, malformed strings, invalid patterns, match structure, and regexp definition errors. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add section covering `as` binding syntax, submatch extraction functions, or-pattern support, and operator restrictions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
This PR is part of a multi-PR chain to implement efficient named pattern in sedlex
This commit does not include any optimization whatsoever. It includes many new tests that will change as we implement optimizations.
Replace ocaml-community#112
Fix #5