FSLex example solution?
f#, fslex, visual-studio
Solution
Unfortunately, there is no built-in item template for .fsl files, because FsLex is a part of PowerPack (so Visual Studio cannot expect that it will be installed). It would be definitely useful to have some template that could be installed with PowerPack!
Anyway, if you're looking for a sample project that uses FsLex (and has .fsl files as part of the project), then you can take a look at the F# source code (distribtued with the Visual Studio 2008 MSI/ZIP package). The project that contains .fsl is `FSharp.Compiler.fsproj` and on my installation, it can be found in `C:\Programs Files\FSharp-1.9.9.9\source\fsharp\FSharp.Compiler`. Surprisingly, it includes a lexer for the F# language itself :-).
To add `FsLex` item to the MSBUILD project (which is also Visual Studio project), it uses the following:
<FsLex Include="..\lex.fsl">
<OtherFlags>--lexlib Internal.Utilities.Text.Lexing</OtherFlags>
<Link>lex.fsl</Link>
</FsLex>
<Compile Include="lex.fs" />
In case you also needed `FsYacc`, here is an example (also from `FSharp.Compiler.fsproj`):
<FsYacc Include="..\pars.fsy">
<Module>Microsoft.FSharp.Compiler.Parser</Module>
<Open>Microsoft.FSharp.Compiler</Open>
<OtherFlags>--internal --lexlib Internal.Utilities.Text.Lexing
--parslib Internal.Utilities.Text.Parsing</OtherFlags>
<Link>pars.fsy</Link>
</FsYacc>
<Compile Include="pars.fs" />
Note that you need the `FsYacc`/`FsLex` command to invoke the custom tool, but also the `Compile` command which tells the compiler to include the produced `fs` file when building the project.
Problem
I've been using C/lex for a long time and would like to use F#/fslex now. I'm comparably well off in C# and in the process of learning F#. The only thing is that I can't see any project example or template where fslex is properly included in the Visual Studio build process. Does anyone know where I can find one? Lots of Greetings! Volker