Skip to content

feat: update CustomLexerContext to CustomLexerCursor#195

Merged
ianlewis merged 1 commit intomainfrom
188-feature-improve-testability
Apr 12, 2026
Merged

feat: update CustomLexerContext to CustomLexerCursor#195
ianlewis merged 1 commit intomainfrom
188-feature-improve-testability

Conversation

@ianlewis
Copy link
Copy Markdown
Owner

@ianlewis ianlewis commented Apr 12, 2026

Description:

Rename CustomLexerContext to CustomLexerCursor and separate it from the context.Context.

Add a NewCustomLexerCursor function to make it easier to create a cursor for testing lexer functions.

Related Issues:

Checklist:

  • Review the CONTRIBUTING.md documentation.
  • Add a reference to a related issue in the repository.
  • Add a description of the changes proposed in the pull request.
  • Add unit tests if applicable.
  • Update documentation if applicable.
  • Add a note in the CHANGELOG.md if applicable.

@ianlewis ianlewis linked an issue Apr 12, 2026 that may be closed by this pull request
@ianlewis ianlewis requested a review from Copilot April 12, 2026 08:03
@ianlewis ianlewis force-pushed the 188-feature-improve-testability branch from fc9b09e to 9e768b1 Compare April 12, 2026 08:05
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the CustomLexer state-machine API by renaming CustomLexerContext to CustomLexerCursor and passing context.Context separately, improving ergonomics for testing lexer state functions (per #188).

Changes:

  • Rename CustomLexerContextCustomLexerCursor and update LexState.Run/LexStateFn to accept (context.Context, *CustomLexerCursor).
  • Add NewCustomLexerCursor(*CustomLexer) helper and update CustomLexer.NextToken to use it.
  • Update README and example/tests to the new cursor-based API.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
custom.go Introduces CustomLexerCursor, updates LexState API and NextToken to pass context.Context separately.
custom_test.go Updates unit tests to use CustomLexerCursor and the new state signature.
lexparse_test.go Updates a lexer test state to match new LexState.Run signature and imports context.
template_example_test.go Updates template lexer example states to accept (context.Context, *CustomLexerCursor).
ini_example_test.go Updates INI lexer example states to accept (context.Context, *CustomLexerCursor).
README.md Updates public documentation/examples for the renamed cursor and new Run signature.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread custom.go
Comment thread custom.go Outdated
Comment thread custom.go
Comment thread custom_test.go Outdated
Comment thread custom_test.go Outdated
Signed-off-by: Ian Lewis <ian@ianlewis.org>
@ianlewis ianlewis force-pushed the 188-feature-improve-testability branch from 9e768b1 to 24ed9bc Compare April 12, 2026 08:18
@ianlewis ianlewis merged commit 0815ae5 into main Apr 12, 2026
24 checks passed
@ianlewis ianlewis deleted the 188-feature-improve-testability branch April 12, 2026 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants