FsLexYacc.Template
1.0.2
dotnet new install FsLexYacc.Template::1.0.2
FsLexYacc Template
This is a Template for the assignments in PRDAT that removes the need to use the FsLexYacc.Runtime.dll file. It will allow you to compile the .fsy and .fsl using dotnet build in the console. Note that some IDE builders might not work as they use specialized build commands.
It also allows you to run the entire thing from an .fsx file, so you don't need to mess around in the console.
You can also just use the Program.fs file if you don't want to use the .fsx.
Install
Run the following to install the template:
dotnet new -i FsLexYacc.Template
How to make a project
Create a new project using the template.
dotnet new fslexyacc -o <project_name>
You can also use the
-oflag to specify the output directory or use-nif you just want it in the current folder.
How to set it up
Replace the
.fsyand.fslwith your own files and update the.csprojfile to match the new names.<FsYacc Include="CPar.fsy"> <OtherFlags>--module CPar</OtherFlags> </FsYacc> <FsLex Include="CLex.fsl"> <OtherFlags>--unicode</OtherFlags> </FsLex>Add the rest of your files to the folder.
Include the files you just added to the
.csprojfile. Make sure to use the order that is used in the commands from the exercise.Example where order is like:
Absyn.fs CPar.fs CPar.fs...fsharpi -r ~/fsharp/FsLexYacc.Runtime.dll Absyn.fs CPar.fs CLex.fs Parse.fs Machine.fs Comp.fs ParseAndComp.fsFeel free to ignore the
.dllas a NuGet package takes care of it.<Compile Include="Absyn.fs" /> <Compile Include="CPar.fs" /> <Compile Include="CLex.fs" /> <Compile Include="Parse.fs" /> <Compile Include="Machine.fs" /> <Compile Include="Comp.fs" /> <Compile Include="ParseAndComp.fs" />Run
dotnet restoreanddotnet buildto make sure everything works.Now just run
dotnet buildevery time you change your.fsyand.fslfiles.You might sometimes need to delete the files
.fsfiles that are generated by the build command.
Using .fsx
- Files with the
.fsxextension are F# scripts that can be used to run code in the interactive terminal. - To load files you use
#load. Make sure that you load all the files you need, in the order you added them in the.csproj. - Just use the
.fsxas you are used toIf you haven't used it before, then you can run a single line by having the cursor on it or run multiple lines by highlighting them, and then press
alt + enter. - You don't need to use
;;in this file like you do in the terminal.
-
net7.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.