Skip to content

refactor: LexParse API#88

Merged
ianlewis merged 1 commit intomainfrom
refactor-api
Feb 19, 2025
Merged

refactor: LexParse API#88
ianlewis merged 1 commit intomainfrom
refactor-api

Conversation

@ianlewis
Copy link
Copy Markdown
Owner

@ianlewis ianlewis commented Feb 19, 2025

Description:

Refactors the lexparse API.

lexparse

  • LexParse now accepts a Lexer and Parser as parameters instead of the initial states. Both the lexer and parser are run in their own goroutines.

lexer

  • Renames State to LexState
  • Renames StateFn to LexStateFn
  • Lexer no longer creates a goroutine. Callers are now responsible for any necessary goroutines.
  • Callers now pass a chan *Lexeme to NewLexer and NewParser allowing the caller more control over the lexeme channel.

parser

  • Adds a new ParseState type to represent parser state.
  • Adds a new ParseStateFn to easily convert a state function into a ParseState.
  • Parser internal state is now protected by a sync.Mutex
  • Removed Node.Left, Node.SetLeft, Node.Right, Node.SetRight, Parser.RotateLeft, Parser.RotateRight.

Related Issues:

Fixes #69

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.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Feb 19, 2025

Codecov Report

Attention: Patch coverage is 93.79310% with 9 lines in your changes missing coverage. Please review.

Project coverage is 89.54%. Comparing base (ec3a3dd) to head (70a101c).

Files with missing lines Patch % Lines
parser.go 91.89% 5 Missing and 1 partial ⚠️
lexer.go 93.75% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #88      +/-   ##
==========================================
- Coverage   91.48%   89.54%   -1.95%     
==========================================
  Files           3        3              
  Lines         470      373      -97     
==========================================
- Hits          430      334      -96     
+ Misses         30       28       -2     
- Partials       10       11       +1     
Files with missing lines Coverage Δ
lexparse.go 100.00% <100.00%> (ø)
lexer.go 86.87% <93.75%> (+0.40%) ⬆️
parser.go 91.93% <91.89%> (-4.65%) ⬇️

@ianlewis ianlewis marked this pull request as ready for review February 19, 2025 08:04
Signed-off-by: Ian Lewis <ian@ianlewis.org>
@ianlewis ianlewis merged commit de0e9ca into main Feb 19, 2025
39 checks passed
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.

Refactor parser API

2 participants