Skip to content
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

Reuse produced reductions table #154

Merged
merged 1 commit into from
Sep 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/FsYacc.Core/fsyaccdriver.fs
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,7 @@ let writeSpecToFile (generatorState: GeneratorState) (spec: ParserSpec) (compile

let getType nt = if types.ContainsKey nt then types.[nt] else generatorState.generate_nonterminal_name nt
begin
writer.Write "let _fsyacc_reductions () =" ;
writer.WriteLine " [| " ;
writer.WriteLine "let _fsyacc_reductions = lazy [|"
for nt,ntIdx,syms,code in compiledSpec.prods do
writer.WriteLine "# %d \"%s\"" writer.OutputLineCount output;
writer.WriteLine " (fun (parseState : %s.IParseState) ->" generatorState.parslib
Expand Down Expand Up @@ -508,7 +507,7 @@ let writeSpecToFile (generatorState: GeneratorState) (spec: ParserSpec) (compile
end;
writer.WriteLine "# %d \"%s\"" writer.OutputLineCount output;
writer.WriteLine "let tables : %s.Tables<_> = " generatorState.parslib
writer.WriteLine " { reductions= _fsyacc_reductions ();"
writer.WriteLine " { reductions = _fsyacc_reductions.Value;"
writer.WriteLine " endOfInputTag = _fsyacc_endOfInputTag;"
writer.WriteLine " tagOfToken = tagOfToken;"
writer.WriteLine " dataOfToken = _fsyacc_dataOfToken; "
Expand Down