-
Notifications
You must be signed in to change notification settings - Fork 72
Make AssocTable cache initial capacity configurable (#54) #238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
nojaf
merged 7 commits into
fsprojects:master
from
larsest1:fix-54-assoctable-grow-on-demand
Jul 6, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8b0f33b
Make AssocTable cache initial capacity configurable (#54)
larsest1 7c6fa47
Add release notes entry for #54
larsest1 444c880
Bump release notes to 11.4.0 (11.3.0 is already released)
larsest1 ba25eb8
Add Interpret overload with explicit AssocTable cache capacity (#54)
larsest1 fd08b0e
Add --assoc-cache-capacity CLI option for fsyacc
larsest1 4e83990
Test that parse results are invariant to AssocTable cache capacity
larsest1 0ed174f
Format with Fantomas
larsest1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| module FsYacc.Core.Tests.AssocCacheCapacity | ||
|
|
||
| open System.IO | ||
| open Expecto | ||
| open FsLexYacc.FsYacc.Driver | ||
|
|
||
| // Generates a parser from a minimal grammar and returns the generated source text, | ||
| // so we can assert on the `engine` line that invokes the runtime interpreter. | ||
| let private generateParser (capacity: int option) = | ||
| let grammar = | ||
| "%token <int> NUM\n\ | ||
| %token EOF\n\ | ||
| %start start\n\ | ||
| %type <int> start\n\ | ||
| %%\n\ | ||
| start: NUM EOF { $1 }\n" | ||
| let input = Path.GetTempFileName() | ||
| let output = Path.GetTempFileName() | ||
| File.WriteAllText(input, grammar) | ||
| try | ||
| let spec = | ||
| match readSpecFromFile input None with | ||
| | Ok s -> s | ||
| | Result.Error(e, line, col) -> failwithf "grammar failed to parse (%d,%d): %s" line col e.Message | ||
| use logger = new NullLogger() :> Logger | ||
| let compiled = compileSpec spec logger | ||
| let state = | ||
| { GeneratorState.Default with | ||
| input = input | ||
| output = Some output | ||
| modname = Some "TestParser" | ||
| parslib = "FSharp.Text.Parsing" | ||
| lexlib = "FSharp.Text.Lexing" | ||
| assocCacheCapacity = capacity } | ||
| writeSpecToFile state spec compiled | ||
| File.ReadAllText output | ||
| finally | ||
| File.Delete input | ||
| if File.Exists output then File.Delete output | ||
|
|
||
| // fsyacc's spec compiler carries process-global mutable state, so the two generation | ||
| // runs must not execute concurrently with each other or with the rest of the suite. | ||
| [<Tests>] | ||
| let assocCacheCapacityTests = | ||
| testSequenced | ||
| <| testList "fsyacc --assoc-cache-capacity" [ | ||
| test "explicit capacity emits the 4-arg Interpret overload" { | ||
| let generated = generateParser (Some 0) | ||
| Expect.stringContains | ||
| generated | ||
| "tables.Interpret(lexer, lexbuf, startState, 0)" | ||
| "generated engine should pass the configured capacity to Interpret" | ||
| } | ||
|
|
||
| test "no capacity emits the default 3-arg Interpret" { | ||
| let generated = generateParser None | ||
| Expect.stringContains | ||
| generated | ||
| "tables.Interpret(lexer, lexbuf, startState)" | ||
| "generated engine should use the parameterless Interpret overload" | ||
| Expect.isFalse | ||
| (generated.Contains "tables.Interpret(lexer, lexbuf, startState,") | ||
| "generated engine should not include a capacity argument when the flag is absent" | ||
| } | ||
| ] |
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://www.nuget.org/packages/FsLexYacc/11.3.0 does appear to be released, could you make this into 11.4.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch — bumped to 11.4.0