FsLexYacc.Template 1.0.2

dotnet new install FsLexYacc.Template::1.0.2                
This package contains a .NET Template Package you can call from the shell/command line.

FsLexYacc Template

GitHub link

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 -o flag to specify the output directory or use -n if you just want it in the current folder.

How to set it up

  1. Replace the .fsy and .fsl with your own files and update the .csproj file to match the new names.

    <FsYacc Include="CPar.fsy">
        <OtherFlags>--module CPar</OtherFlags>
    </FsYacc>
    <FsLex Include="CLex.fsl">
        <OtherFlags>--unicode</OtherFlags>
    </FsLex>
    
  2. Add the rest of your files to the folder.

  3. Include the files you just added to the .csproj file. 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.fs

    Feel free to ignore the .dll as 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" />
    
  4. Run dotnet restore and dotnet build to make sure everything works.

  5. Now just run dotnet build every time you change your .fsy and .fsl files.

    You might sometimes need to delete the files .fs files that are generated by the build command.

Using .fsx

  1. Files with the .fsx extension are F# scripts that can be used to run code in the interactive terminal.
  2. 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.
  3. Just use the .fsx as you are used to

    If 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.

  4. 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.

Version Downloads Last updated
1.0.2 1,918 9/14/2023
1.0.1 1,551 9/14/2023