GithubHelp home page GithubHelp logo

fsprojects / fslexyacc Goto Github PK

View Code? Open in Web Editor NEW
202.0 25.0 68.0 3.32 MB

Lexer and parser generators for F#

Home Page: http://fsprojects.github.io/FsLexYacc/

License: MIT License

Shell 0.02% F# 96.17% Batchfile 0.02% 1C Enterprise 3.79%
fsharp lexer lex yacc parser

fslexyacc's Introduction

FsLexYacc

FsLex and FsYacc tools

See https://fsprojects.github.io/FsLexYacc.

  • FsLexYacc.Runtime - NuGet Badge
  • FsLexYacc - NuGet Badge

Build the project

Build Status

  • Unix: Run build.sh
  • Windows: Run build.cmd

Maintainer(s)

The default maintainer account for projects under "fsprojects" is @fsprojectsgit - F# Community Project Incubation Space (repo management)

fslexyacc's People

Contributors

auduchinok avatar baronfel avatar belczyk avatar brodyberg avatar cartermp avatar dawedawe avatar dependabot[bot] avatar dsyme avatar dungpa avatar enricosada avatar fangyi-zhou avatar forki avatar fsgit avatar fsprojectsgit avatar gdziadkiewicz avatar kkm000 avatar koeniglear avatar moonmile avatar mrgleba avatar nojaf avatar panesofglass avatar pblasucci avatar reedcopsey avatar rojepp avatar ronnieholm avatar sergey-tihon avatar teo-tsirpanis avatar thautwarm avatar tpetricek avatar xp44mm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fslexyacc's Issues

parseState.ResultRange reports incorrect position info

Description

parseState.ResultRange reports incorrect position info when filename isn't set to lexbuf.EndPos.

Repro steps

I have uploaded repro here.

https://github.com/nshibano/FsLexYacc-report-20161111

To run the repro, please clone this repository and open ConsoleApplication3.sln and click run button. (The first run will fail because of nuget files isn't loaded. Restart VisualStudio and try again to reload.)

In this sample application, text "ABC" is parsed with very simple lexing/parsing rules. And parser returns position range obtained from parseState.ResultRange. Therefore position info should point entire text "ABC". However, reported range is incorrect and it points only part of it, "BC".

This glitch happens only when filename isn't set to lexbuf.EndPos. With filename set, parseState.ResultRange reports correct position.

Here is the output from sample application.

Range is 1 to 3.
Substring is "BC"
Try again with filename set to lexbuf.
Range is 0 to 3.
Substring is "ABC"

Known workarounds

To avoid this glitch, set filename to lexbuf.EndPos.

Related information

Visual Studio 2015

LexAndYaccMiniProject test project build fails

Attempting to build FsLexYacc / tests / LexAndYaccMiniProject / fails with the following error.

1>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1819,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "FsLexYacc.Runtime". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.

error recovery is poorly documented

Documentation for options for parse error handling and recovery are nonexistent. When a parse error occurs, what happens? What options are available for handling this error? How can I provide custom behavior for the exception that is raised when a parse error occurs?

Support netstandard

Right now only net461 is targetted.
It would be nice to have a netstandard[something] build.

.targets and build tools are packaged to /bin, not /build

NuGet (starting with v2.5, I believe) will auto-import all .targets files from packaged /build directory to the project. I just built a package locally with the target file and all tools moved to /build, and it added its targets properly. With the binary package from nuget.org that does not happen.

Is this a bug or done on purpose?

Weird context sensitive error in FStar's parse

Description

I am working on the fsyacc generated FStar parser (parse.fsy) and am experiencing some troublesome and hard to debug behaviours. Some productions seems to fail to parse if they are not parsed after some unrelated production. As an example the following does not parse :

module DoesNotParse

let x = ()

(as tokens : MODULE ; NAME "DoesNotParse" ; LET false ; IDENT "x" ; EQUALS ; LPAREN_RPAREN ; EOF )

whereas adding an unrelated declaration beforehand makes the parsing go through :

module DoesParse

val y : int
let x = ()

(as tokens : MODULE ; NAME "DoesParse" ; VAL ; IDENT "y" ; COLON ; IDENT "int" ; LET false ; IDENT "x" ; EQUALS ; LPAREN_RPAREN ; EOF)

Repro steps

  1. Build fsharp's FStar from kyod_parser branch (from top directory execute make -C src)

  2. Execute the two previous files with fstar
    fstar.exe --explicit_deps doesNotParse.fst
    fstar.exe --explicit_deps doesParse.fst

Expected behavior

Any let declaration should be able to parse even just after the module declaration (using productions input_fragment ; decl ; decl2). It works fine with both the ocamlyacc and menhir parser generators from which the fsyacc parser is generated (the transformation from ocamlyacc format to fsyacc format is just a line of sed).

Actual behavior

Such a let declaration does not parse unless there is a val declaration beforehand (which is also produced by decl2). This misbehaviour has also been witnessed with some other tokens previously (but which seems more difficult to debug).

Tested with nuget packages 6.1.0 and 7.02 (for both FsLexYacc and the runtime). I will try to minimize the parser to find where the error is comming from. I also would like to use the debug facilites in fsyacc (I saw in the code that there is some Flag.debug which can be enabled if __DEBUG is defined at compile time) but I didn't manage to build Fsyacc from sources... Is there some way to have this enabled with a nuget package ?

Windows Appveyor build fails on alternate PRs

Description

Since PR 50 the Appveyor Windows build has failed in OldFsYaccTests.fsx on every other build.

Running 'test1-unicode.exe' with args '--tokens .\test1.input1'

Although it fails at the same point, it seems to be arbitrary in that the next PR build will succeed, and I cannot replicate the failure locally.

Repro steps

Merge PR.

Expected behavior

Appveyor should complete, and it does on alternate runs.

Actual behavior

Fails after every other run

Known workarounds

Build will eventually succeed on next run (if the pattern holds).

Related information

Last failure on merge


0.0.1.107

4 days ago  by Don Syme ```

AssocTable ctor is expensive

Description

When using fsyacc for parsing of smaller test strings, the ctor of the AssocTable is very expensive (relative to the actual parsing). This is due to the initial size of the dictionary cache (2000).

This seems to be a semi-known issue as a comment in the code states:
// Note: using a .NET Dictionary for this int -> int table looks like it could be sub-optimal.
// Some other better sparse lookup table may be better.

Repro steps

Profiling a parse of any small input shows that "AssocTable..ctor" includes a significant portion of samples, and that "Dictionary`2[System.Int32,System.Int32]..ctor" is the culprit. Compiling with a smaller initial cache size (e.g. 20) increases the performance for these inputs.

Expected behavior

I expect it to be either just cheaper, or configurable in some way so that this will yield better performance for smaller parsing inputs.

Actual behavior

Not able to configure this in any way right now.

Tool-generated fs files must be included in project

I am wondering is it possible to modify msbuild process for a project with fsl/fsy sources in such a way that the .fs files generated by respective FsLex and FsYacc tasks be treated as temporary, and added to the list of files for compiling dynamically after running the tools. Now I have the 2 output .fs files included in project and checked in under source control, and they are not rebuilt when I select rebuild in Visual Studio.

From what I understand of msbuild, this should be possible, but my experience may be limited. Or am I just doing it wrong?

Incorrect self-referencing line directives in generated files

Generated source files (.fs) from both fslex and fsyacc contain line directives. Inserted directives are good when referencing external files (such as source .fsl/.fsy) but are incorrect when referencing the generated file itself. Line number should contain the next line for tooling (such as syntax highlighting, etc.) to work properly.

For example, incorrect line numbers in file.fs that can be generated now are:

# 1 "file.fs" // this is the actual line 1, stating that the next line number is 1 (incorrect)
// some code on line 2

Correct directive that should be generated is:

# 2 "file.fs" // this is the actual line 1, stating that the next line number is 2 (correct)
// some code on line 2

Switch to SDK-style projects!

@dsyme, I want to use SDK-style MSBuild projects instead of FAKE and Packet. These tools were a very good solution to packaging and dependency maintenance issues in "classic" projects, but these same problems are solved by dotnet SDK in a different way. I could not tame Paket to upgrade the runtime to make tests runnable on AppVeyor in #86--it kept inserting hundreds of lines of XML with target conditions into every project file. The SDK keeps this uglity under the hood.

This would take care of #78 as well.

What is your take on this? Can you think of a reason why we cannot use it?

Please rename Microsoft.Text.Lexing/Parsing to FsLexYacc.Runtime.Lexing/Parsing

Now this project is on github as an independent "FsLexYacc" project, it's inappropriate for the Runtime component to be using the names

Microsoft.Text.Lexing 
Microsoft.Text.Parsing

I suggest they be renamed to

FsLexYacc.Runtime.Lexing
FsLexYacc.Runtime.Parsing

I think the rename should just be done and the minor version number bumped - it's a breaking change but a good one in the long term, and people who want the old naming can go to the old F# power pack.

An alternative is

FsLex.Runtime
FsYacc.Runtime

But I don't like that since the name of the overall technology is "FsLexYacc" and the two technologies really aren't independent in any particularly meaningful way.

FsLexYacc.Runtime.dll does not represent a strongly named assembly

I'm moving a F# project building dependencies from FsLexYacc 6.* to FsLexYacc 7.0.6.0. I can build it out successfully. But When running my executable I occur this failure:

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'FsLexYacc.Runtime, Version=7.0.6.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)

Then I checked FsLexYacc.Runtime.dll with sn:

>sn -vf FsLexYacc.Runtime.dll

Microsoft (R) .NET Framework Strong Name Utility  Version 4.0.30319.0
Copyright (c) Microsoft Corporation.  All rights reserved.

FsLexYacc.Runtime.dll does not represent a strongly named assembly

I looked though FsLexYacc.Runtime.fsproj and didn't find signing process

Of cause best solution is add signing process to project setting, officially or locally.
Do I have workarounds to using prebuilt FsLexYacc.Runtime.dll from NuGet? I don't want rebuild from source code.

Redirect FsLex/FsYacc output to VS Output window

Is it possible to redirect FsLex/FsYacc output to VS Output window?

In case of error in VS Output window I see

D:\MyParser\packages\FsLexYacc.6.0.1\bin\fslex.exe -o obj\Debug\Lexer.fs --unicode  Lexer.fsl 
D:\MyParser\packages\FsLexYacc.6.0.1\bin\FsLexYacc.targets(32,3): error MSB6006: "fslex.exe" exited with code 1.
Done building project "MyParser.fsproj" -- FAILED.

But in console window I see the error message

Lexer.fsl(35,0): error: unterminated string in code

Issue with reduce/reduce conflicts

Consider this grammar file:

%token ONE MINUS MIN

%left MINUS
%right UMINUS
%right MIN

%start Exp
%type Exp

%%

Exp:
ONE { 1 }
| Exp MINUS Exp { $1 - $3) }
| MINUS Exp %prec UMINUS { - $2 }
| MIN Exp Exp { min $2 $3 }
;

%%

With mosmlyac, this generates no conflict, but with fsyacc, it generates three reduce/reduce conflicts:

state 4: reduce/reduce error on ONE
state 4: reduce/reduce error on MINUS
state 4: reduce/reduce error on MIN

State 4 has the following items:

Exp -> Exp . 'MINUS' Exp
Exp -> Exp 'MINUS' Exp . 
Exp -> 'MINUS' Exp .

Given that the unary minus has higher precedence than the infix minus, there should be no conflict: There should be a reduce on the last production in the item set. So it seems that precedence declarations are ignored when resolving reduce/reduce conflicts.

Peter Sestoft tells me that he resolved this issue in mosmlyac (which is also based on ocamlyacc), as well as an isse with %nonassoc, around 10 years ago.

Cannot build LexAndYaccMiniProject on mono 3.2.7

This is independent of #4. After I set the executable bit to work around that issue, I then get a strange MSBuild issue. I had a look over the project file but I couldn't see anything obviously wrong. Perhaps my mono is too old?

Warnings:

:  warning : Default tasks file MSBuild/12.0/bin/Microsoft.Common.tasks not found, ignoring.

Errors:

LexAndYaccMiniProject.fsproj: error :
/auto/users/robnea/dev/tmp/FsLexYacc/tests/LexAndYaccMiniProject/LexAndYaccMiniProject.fsproj:
/home/scratch/local/lib/mono/xbuild/Microsoft/VisualStudio/v/FSharp/Microsoft.FSharp.Targets:
Project file could not be imported, it was being imported by
/auto/users/robnea/dev/tmp/FsLexYacc/tests/LexAndYaccMiniProject/LexAndYaccMiniProject.fsproj:
/home/scratch/local/lib/mono/4.0/Microsoft.FSharp.Targets:
Project file could not be imported, it was being imported by
/home/scratch/local/lib/mono/xbuild/Microsoft/VisualStudio/v/FSharp/Microsoft.FSharp.Targets:
/home/scratch/local/lib/mono/4.0/Microsoft.FSharp.Targets could
not import "$(MSBuildBinPath)\Microsoft.Common.targets"

Build fails using FsLexYacc.6.0.4.0 and FSPowerPack.Core.Community.3.0.0.0

I'm doing a research project using FsLex and FsYacc, and when I moved from Visual Studio 2012 and the old FSharpPowerPack v 4.0 to Visual Studio 2013, FsLexYacc.6.0.4 and FSPowerPack.Core.Community.3.0.0.0, the compiler gives me this 'strange' error:

error FS0001: Type mismatch. Expecting a� LexBuffer -> 'a �but given a� LexBuffer -> token �The type 'Microsoft.FSharp.Text.Lexing.LexBuffer<Microsoft.FSharp.Core.char>' does not match the type 'Microsoft.FSharp.Text.Lexing.LexBuffer<Microsoft.FSharp.Core.char>'

I checked very well all the references and I found that both FsLexYacc.Runtime.6.0.4 and FSPowerPack.Core.Community.3.0.0.0 have a module named Microsoft.FSharp.Text.Lexing with a definition of LexBuffer. I need both the references because I use Microsoft.FSharp.Text.StructuredFormat.

How can I address this?
Should I use only FsLex and FsYacc bundled in the FSPowerPack.Core.Community.3.0.0.0 package?

Below the complete building log

1>------ Build started: Project: Text, Configuration: Release Any CPU ------
2>------ Build started: Project: JSContainer, Configuration: Release Any CPU ------
3>------ Build started: Project: ChromePreludeJS, Configuration: Release Any CPU ------
1> "C:\Users\PHD\Desktop\JunkScratch\chen2\CHEN.nuget\NuGet.exe" install "C:\Users\PHD\Desktop\JunkScratch\chen2\Libs\Text\packages.config" -source "" -NonInteractive -RequireConsent -solutionDir "C:\Users\PHD\Desktop\JunkScratch\chen2\CHEN\ "
1> Restoring NuGet packages...
1> To prevent NuGet from downloading packages during build, open the Visual Studio Options dialog, click on the Package Manager node and uncheck 'Allow NuGet to download missing packages'.
1> All packages listed in packages.config are already installed.
1> C:\Program Files (x86)\Microsoft SDKs\F#\3.1\Framework\v4.0\fsc.exe -o:obj\Release\Text.dll --debug:pdbonly --noframework --define:TRACE --doc:bin\Release\Text.XML --optimize+ -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\FSharp.NETFramework\v4.0\4.3.1.0\FSharp.Core.dll" -r:C:\Users\PHD\Desktop\JunkScratch\chen2\CHEN\packages\FSPowerPack.Core.Community.3.0.0.0\Lib\Net40\FSharp.PowerPack.dll -r:C:\Users\PHD\Desktop\JunkScratch\chen2\CHEN\packages\FsLexYacc.Runtime.6.0.4\lib\net40\FsLexYacc.Runtime.dll -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\mscorlib.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\System.Core.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\System.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\System.Numerics.dll" --target:library --warn:3 --warnaserror:76 --vserrors --validate-type-providers --LCID:1033 --utf8output --fullpaths --flaterrors --subsystemversion:6.00 --highentropyva+ --sqmsessionguid:abcdd0da-27f3-429a-990e-e02155fc9da3 "C:\Users\PHD\AppData\Local\Temp.NETFramework,Version=v4.5.AssemblyAttributes.fs" PrettyPrint.fsi PrettyPrint.fs PrettySeqs.fs
2> JSContainer -> C:\Users\PHD\Desktop\JunkScratch\chen2\CHEN\JSContainer\bin\Release\JSContainer.dll
3> ChromePreludeJS -> C:\Users\PHD\Desktop\JunkScratch\chen2\CHEN\ChromePreludeJS\bin\Release\ChromePreludeJS.dll
1> Text -> C:\Users\PHD\Desktop\JunkScratch\chen2\Libs\Text\bin\Release\Text.dll
4>------ Build started: Project: Utils, Configuration: Release Any CPU ------
4> "C:\Users\PHD\Desktop\JunkScratch\chen2\CHEN.nuget\NuGet.exe" install "C:\Users\PHD\Desktop\JunkScratch\chen2\Libs\Utils\packages.config" -source "" -NonInteractive -RequireConsent -solutionDir "C:\Users\PHD\Desktop\JunkScratch\chen2\CHEN\ "
4> Restoring NuGet packages...
4> To prevent NuGet from downloading packages during build, open the Visual Studio Options dialog, click on the Package Manager node and uncheck 'Allow NuGet to download missing packages'.
4> All packages listed in packages.config are already installed.
4> C:\Program Files (x86)\Microsoft SDKs\F#\3.1\Framework\v4.0\fsc.exe -o:obj\Release\Utils.dll --debug:pdbonly --noframework --define:TRACE --doc:bin\Release\Utils.XML --optimize+ -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\FSharp.NETFramework\v4.0\4.3.1.0\FSharp.Core.dll" -r:C:\Users\PHD\Desktop\JunkScratch\chen2\CHEN\packages\FSPowerPack.Core.Community.3.0.0.0\Lib\Net40\FSharp.PowerPack.dll -r:C:\Users\PHD\Desktop\JunkScratch\chen2\CHEN\packages\FsLexYacc.Runtime.6.0.4\lib\net40\FsLexYacc.Runtime.dll -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\mscorlib.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\System.Core.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\System.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\System.Numerics.dll" -r:C:\Users\PHD\Desktop\JunkScratch\chen2\Libs\Text\bin\Release\Text.dll --target:library --warn:3 --warnaserror:76 --vserrors --validate-type-providers --LCID:1033 --utf8output --fullpaths --flaterrors --subsystemversion:6.00 --highentropyva+ --sqmsessionguid:abcdd0da-27f3-429a-990e-e02155fc9da3 "C:\Users\PHD\AppData\Local\Temp.NETFramework,Version=v4.5.AssemblyAttributes.fs" Log.fs Prelude.fs PrettyPrint.fs Collections.fs Monad.fs ParsingUtils.fs Processes.fs Env.fs SpeedStats.fs Runtime.fs Args.fs
4>C:\Users\PHD\Desktop\JunkScratch\chen2\Libs\Utils\Monad.fs(294,126): warning FS0064: This construct causes code to be less generic than indicated by the type annotations. The type variable 'a has been constrained to be type 'unit'.
4> Utils -> C:\Users\PHD\Desktop\JunkScratch\chen2\Libs\Utils\bin\Release\Utils.dll
5>------ Build started: Project: CHEN, Configuration: Release Any CPU ------
5> "C:\Users\PHD\Desktop\JunkScratch\chen2\CHEN.nuget\NuGet.exe" install "C:\Users\PHD\Desktop\JunkScratch\chen2\CHEN\CHEN\packages.config" -source "" -NonInteractive -RequireConsent -solutionDir "C:\Users\PHD\Desktop\JunkScratch\chen2\CHEN\ "
5> Restoring NuGet packages...
5> To prevent NuGet from downloading packages during build, open the Visual Studio Options dialog, click on the Package Manager node and uncheck 'Allow NuGet to download missing packages'.
5> All packages listed in packages.config are already installed.
5> C:\Users\PHD\Desktop\JunkScratch\chen2\CHEN\packages\FsLexYacc.6.0.4\bin\fslex.exe -o obj\Release\Lexer.fs --unicode Lexer.fsl
5> compiling to dfas (can take a while...)
5> 477 states
5> writing output
5> C:\Users\PHD\Desktop\JunkScratch\chen2\CHEN\packages\FsLexYacc.6.0.4\bin\fsyacc.exe -o obj\Release\Parser.fs --module CHEN.Parser Parser.fsy
5> building tables
5> computing first function...time: 00:00:00.0668894
5> building kernels...time: 00:00:00.0761981
5> building kernel table...time: 00:00:00.0216786
5> computing lookahead relations................................................................................................................................................................................time: 00:00:00.0658148
5> building lookahead table...time: 00:00:00.0238613
5> building action table...time: 00:00:00.0513454
5> building goto table...time: 00:00:00.0044148
5> returning tables.
5> 173 states
5> 13 nonterminals
5> 88 terminals
5> 103 productions
5> #rows in action table: 173
5> C:\Program Files (x86)\Microsoft SDKs\F#\3.1\Framework\v4.0\fsc.exe -o:obj\Release\CHEN.exe --debug:pdbonly --noframework --define:TRACE --doc:bin\Release\CHEN.XML --optimize+ --platform:anycpu -r:C:\Users\PHD\Desktop\JunkScratch\chen2\CHEN\ChromePreludeJS\bin\Release\ChromePreludeJS.dll -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\FSharp.NETFramework\v4.0\4.3.1.0\FSharp.Core.dll" -r:C:\Users\PHD\Desktop\JunkScratch\chen2\CHEN\packages\FSPowerPack.Core.Community.3.0.0.0\Lib\Net40\FSharp.PowerPack.dll -r:C:\Users\PHD\Desktop\JunkScratch\chen2\CHEN\packages\FsLexYacc.Runtime.6.0.4\lib\net40\FsLexYacc.Runtime.dll -r:C:\Users\PHD\Desktop\JunkScratch\chen2\CHEN\JSContainer\bin\Release\JSContainer.dll -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\mscorlib.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\System.Core.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\System.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\System.Numerics.dll" -r:C:\Users\PHD\Desktop\JunkScratch\chen2\Libs\Text\bin\Release\Text.dll -r:C:\Users\PHD\Desktop\JunkScratch\chen2\Libs\Utils\bin\Release\Utils.dll --target:exe --warn:3 --warnaserror:76 --vserrors --validate-type-providers --LCID:1033 --utf8output --fullpaths --flaterrors --subsystemversion:6.00 --highentropyva+ --sqmsessionguid:abcdd0da-27f3-429a-990e-e02155fc9da3 "C:\Users\PHD\AppData\Local\Temp.NETFramework,Version=v4.5.AssemblyAttributes.fs" AssemblyInfo.fs Permissions.fs Syntax.fs AbstractTypes.fs AbstractOp.fs PreParsing.fs obj\Release\Parser.fs obj\Release\Lexer.fs Parsing.fs ARename.fs Traverse.fs GenTypes.fs ConstraintGenerator.fs ConstraintSolver.fs Driver.fs Args.fs Program.fs
5>C:\Users\PHD\Desktop\JunkScratch\chen2\CHEN\CHEN\AbstractTypes.fs(57,11): warning FS0025: Incomplete pattern matches on this expression.
5>C:\Users\PHD\Desktop\JunkScratch\chen2\CHEN\CHEN\AbstractTypes.fs(715,11): warning FS0026: This rule will never be matched
5>C:\Users\PHD\Desktop\JunkScratch\chen2\CHEN\CHEN\AbstractTypes.fs(557,5): warning FS0343: The type 'ValAt' implements 'System.IComparable' explicitly but provides no corresponding override for 'Object.Equals'. An implementation of 'Object.Equals' has been automatically provided, implemented via 'System.IComparable'. Consider implementing the override 'Object.Equals' explicitly
5>C:\Users\PHD\Desktop\JunkScratch\chen2\CHEN\CHEN\AbstractTypes.fs(663,5): warning FS0346: The struct, record or union type 'ValAtTop' has an explicit implementation of 'Object.Equals'. Consider implementing a matching override for 'Object.GetHashCode()'
5>C:\Users\PHD\Desktop\JunkScratch\chen2\CHEN\CHEN\AbstractTypes.fs(708,5): warning FS0346: The struct, record or union type 'ValAtTopSerializable' has an explicit implementation of 'Object.Equals'. Consider implementing a matching override for 'Object.GetHashCode()'
5>C:\Users\PHD\Desktop\JunkScratch\chen2\CHEN\CHEN\Parsing.fs(39,37): error FS0001: Type mismatch. Expecting a� (Lexing.LexBuffer -> 'a) -> Lexing.LexBuffer -> 'b �but given a� (Lexing.LexBuffer -> token) -> Lexing.LexBuffer -> Syntax.Program �The type 'Microsoft.FSharp.Text.Lexing.LexBuffer<Microsoft.FSharp.Core.char>' does not match the type 'Microsoft.FSharp.Text.Lexing.LexBuffer<Microsoft.FSharp.Core.char>'
5>C:\Users\PHD\Desktop\JunkScratch\chen2\CHEN\CHEN\Parsing.fs(39,45): error FS0001: Type mismatch. Expecting a� Lexing.LexBuffer -> 'a �but given a� Lexing.LexBuffer -> token �The type 'Microsoft.FSharp.Text.Lexing.LexBuffer<Microsoft.FSharp.Core.char>' does not match the type 'Microsoft.FSharp.Text.Lexing.LexBuffer<Microsoft.FSharp.Core.char>'
5>C:\Users\PHD\Desktop\JunkScratch\chen2\CHEN\CHEN\ConstraintGenerator.fs(104,11): warning FS0025: Incomplete pattern matches on this expression.
5>C:\Users\PHD\Desktop\JunkScratch\chen2\CHEN\CHEN\ConstraintSolver.fs(292,17): warning FS0025: Incomplete pattern matches on this expression.
5>Done building project "CHEN.fsproj" -- FAILED.
5>
5>Build FAILED.
========== Build: 4 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

%nonassoc not handled correctly

%nonassoc is not handled correctly: When an operator (say, NEQ) is declared nonassociative, there should be no shift/reduce conflict on a state containing items

Exp -> Exp . 'NEQ' Exp
Exp -> Exp 'NEQ' Exp .

Instead, BOTH the shift and the reduce actions should be eliminated if the next symbol is NEQ. This will cause (correctly) a parse error on, say,
Exp NEQ Exp NEQ Exp. As it is, it parses equivalently to Exp NEQ (Exp NEQ Exp).

A very simple grammar file that shows the problem is

%token ONE NEQ
%nonassoc NEQ
%start Exp
%type Exp

%%
Exp : ONE {1}
| Exp NEQ Exp {if $1 = $3 then 0 else 1}
%%

Peter Sestoft tells me that he corrected this error (and one having to do with reduce/reduce conflicts) in mosmlyac (which is also based on ocamlyacc) about 10 years ago.

Generation of standalone lexer/parser source file

By default, generated lexer/parser .fs file needs external FsLexYacc.Runtime library. But in some situation, standalone .fs file is useful. For example,

  • When you don't want to add package dependency to FsLexYacc and/or FsLexYacc.Runtime
  • When the .NET version you are targeting is incompatible with FsLexYacc.Runtime's one

Available solution close to standalone .fs file is below.

  1. Download .nuget package, rename it to .zip, extract fslex.exe and fsyacc.exe.
  2. Using these .exe's, compile .fsl and .fsy with appropriate --lexlib and --parselib options.
  3. The zip archive created in step 1 also contains source files of lexer/parser runtime. Find Lexing.fs and Parsing.fs and copy them to your project and rename namespaces in it if needed.
  4. Compile everything together.

Update: Recent nuget package contains lexer/parser runtime source. Changed workflow to use it.

NuGet does not work on Xamarin.iOS

The NuGet doesn't work with Xamarin.iOS on a Mac.

While Xamarin Studio has basic support for NuGet (not sure if it supports targets), it's not able to install the package because the runtime is not compatible:

Adding FsLexYacc...
Downloading FsLexYacc 6.0.1...
Installing 'FsLexYacc 6.0.1'.
Added file 'FSharp.Core.dll' to folder 'FsLexYacc.6.0.1/bin'.
Added file 'fslex.exe' to folder 'FsLexYacc.6.0.1/bin'.
Added file 'fsyacc.exe' to folder 'FsLexYacc.6.0.1/bin'.
Added file 'FsLexYacc.targets' to folder 'FsLexYacc.6.0.1/bin'.
Added file 'FsLexYacc.Build.Tasks.dll' to folder 'FsLexYacc.6.0.1/bin'.
Added file 'FsLexYacc.Runtime.dll' to folder 'FsLexYacc.6.0.1/lib/net40'.
Added file 'FsLexYacc.Runtime.xml' to folder 'FsLexYacc.6.0.1/lib/net40'.
Added file 'FsLexYacc.6.0.1.nupkg' to folder 'FsLexYacc.6.0.1'.
Successfully installed 'FsLexYacc 6.0.1'.
Adding 'FsLexYacc 6.0.1' to Mecha.Core.
Could not install package 'FsLexYacc 6.0.1'. You are trying to install this package into a project that targets 'MonoTouch,Version=v1.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

Honestly, I don't need the IDE integration and would be fine with just downloading the EXEs and running them from the command line. That is, a ZIP file of the distribution would be great. :-)

Then a PCL or MonoTouch version of the runtime (Lexing and Parsing modules) is needed.

Build fails on Mono as fs{lex,yacc}.exe not executable

Mono's Process.Start will not run a .exe file unless it is marked exectuable. It's not clear if this behaviour is deliberate or not. See this bug report: https://bugzilla.xamarin.com/show_bug.cgi?id=17537

The lkg bootstrap fs{lex,yacc}.exe do not have executable permission set and so the build fails (error at the bottom).

However, this is not just a problem for the build, if the permissions are not set in the NuGet package either, then this package cannot be used on Mono without a manual step (such as find packages -name "*.exe" | xargs chmod +x) after the package is downloaded. How can we address this? Is it possible to run a postinstall script on the package for example, or (less clean) to adjust the FsLex and FsYacc MSBuild tasks so that they set the executable bit on Mono before running?

/auto/users/robnea/dev/tmp/FsLexYacc/FsLexYacc.sln (Rebuild) ->
(Rebuild target) ->
/auto/users/robnea/dev/tmp/FsLexYacc/src/FsLex/FsLex.fsproj (Rebuild) ->
/auto/users/robnea/dev/tmp/FsLexYacc/lkg/FSharp.PowerPack-1.9.7.7/bin/FSharp.PowerPack.targets (CallFsLex target) ->

    /auto/users/robnea/dev/tmp/FsLexYacc/lkg/FSharp.PowerPack-1.9.7.7/bin/FSharp.PowerPack.targets: error : Error executing tool '../../lkg/FSharp.PowerPack-1.9.7.7/bin/FsLex.exe': ApplicationName='../../lkg/FSharp.PowerPack-1.9.7.7/bin/FsLex.exe', CommandLine='-o fslexlex.fs --unicode --lexlib Internal.Utilities.Text.Lexing  fslexlex.fsl ', CurrentDirectory='/auto/users/robnea/dev/tmp/FsLexYacc/src/FsLex', Native error= Cannot find the specified file

/auto/users/robnea/dev/tmp/FsLexYacc/FsLexYacc.sln (Rebuild) ->
(Rebuild target) ->
/auto/users/robnea/dev/tmp/FsLexYacc/src/FsYacc/FsYacc.fsproj (Rebuild) ->
/auto/users/robnea/dev/tmp/FsLexYacc/lkg/FSharp.PowerPack-1.9.7.7/bin/FSharp.PowerPack.targets (CallFsLex target) ->

    /auto/users/robnea/dev/tmp/FsLexYacc/lkg/FSharp.PowerPack-1.9.7.7/bin/FSharp.PowerPack.targets: error : Error executing tool '../../lkg/FSharp.PowerPack-1.9.7.7/bin/FsLex.exe': ApplicationName='../../lkg/FSharp.PowerPack-1.9.7.7/bin/FsLex.exe', CommandLine='-o fsyacclex.fs --unicode --lexlib Internal.Utilities.Text.Lexing  fsyacclex.fsl ', CurrentDirectory='/auto/users/robnea/dev/tmp/FsLexYacc/src/FsYacc', Native error= Cannot find the specified file

Links in documentation website are broken

Description

The links in the Getting Started and Documentation section are broken. They point to:

file:///C:/GitHub/dsyme/FsLexYacc/docs/fslex.html
file:///C:/GitHub/dsyme/FsLexYacc/docs/fsyacc.html
file:///C:/GitHub/dsyme/FsLexYacc/docs/reference/index.html

Repro steps

Visit http://fsprojects.github.io/FsLexYacc/, look at the links at the bottom of the sidebar.

Expected behavior

Links should point to the right place.

Actual behavior

They don't.

Known workarounds

Use the links in the main part of the page.

target file Error

I'm currently trying to set up a simple parser project to include in other project later so i just need to alter the fsl and fsp files. but at the moment I'm stock. This is first time I use Fsyacc in Visual studio. But i got the warning: The namespace 'Lexing' is not defined. when I try to call it from the fsl file. I use the example files given.

I think it's because of the error
The command
""C:\Users\KAM.nuget\packages\fslexyacc\9.0.2\build\ /fsyacc/net46\fsyacc.exe" -o "Lexer.fs" --unicode Lexer.fsl" exited with code 9009.

Do anyone no how to fix this ?

Publish FsLexYacc.Runtime as a separate NuGet package

The FsLexYacc.Runtime assembly should be published a separate NuGet package (i.e., apart from the fslex and fsyacc tools and build tasks). This would allow me to re-use the package for facio -- I could just reference the FsLexYacc.Runtime package instead of having to build and ship the runtime with facio; it would also make it possible to produce a NuGet package that targets multiple framework versions and profiles (e.g., net20, net40-Client, Xamarin.iOS) which isn't really feasible as long as the runtime is packaged with the tools.

Doc generation not working

,\build GenerateDocs

gives

generate.fsx(25,1): warning FS0211: The search directory 'C:\GitHub\dsyme\FsLexY
acc\docs\tools\../../packages/FSharp.Formatting.2.4.17/lib/net40' could not be f
ound


generate.fsx(26,1): warning FS0211: The search directory 'C:\GitHub\dsyme\FsLexY
acc\docs\tools\../../packages/RazorEngine.3.3.0/lib/net40' could not be found


generate.fsx(27,1): warning FS0211: The search directory 'C:\GitHub\dsyme\FsLexY
acc\docs\tools\../../packages/FSharp.Compiler.Service.0.0.58/lib/net40' could no
t be found

Suggestion: place code block from .fsy after token declaration in generated .fs

Now the code block surrounded by %{ and %} is output before the token type declaration in .fs file. This prevents error handler from using token type directly and requires boxing/unboxing trick. Outputting the code block after the token type declaration and related helper functions such as token_to_string can simplify writing rich error handlers which depend on token type. And only drawback I can see is that if the code block opens a namespace, this opened namespace will not be available in token types. But it is not a problem really, especially because the code block is not output to the .fsi file and .fsi code will not be vaild either if token elements use namespaces opened in code block.

Variables in supplied ".target" file seems undefined leading to compilation error

Description

I have the following issue :

2>------ Rebuild All started: Project: <project>, Configuration: Release x64 ------
2>		"\"  -o "Lexer.fs" --unicode Lexer.fsl
2>		'"\"' n'est pas reconnu en tant que commande interne
2>		ou externe, un programme exécutable ou un fichier de commandes.
2><projectdir>\packages\FsLexYacc.10.2.0\build\fsyacc\netcoreapp3.1\FsLexYacc.targets(36,3): error MSB3073: The command ""\"  -o "Lexer.fs" --unicode Lexer.fsl" exited with code 9009.

(I replaced my project name and directory with <> in the copied text above)
(the text in french translate to :"...is not recognized as an internal or external command, executable program, or batch file.")

For the first part of the command to be "\", I suspect some variables in the file "FsLexYacc.targets" gets undefined (path and exec I guess), which seems to lead to faulty command.

I had been using the library without any problems up to date, this problem came when I migrated from version 10.0 to 10.2 of FsLexYacc.

The project is built with Visual Studio 2019, and the framework is ".NET Framework 4.6.1".

Known workarounds

None known.

Related information

  • Operating system : Windows
  • .NET Runtime : .NET Framework 4.6.1

Thanks in advance !

How can I count/enumerate all syntax errors that occur while parsing?

Sorry this is more a question than an issue. I know I can try-catch parse errors and get line number information from the lex buffer, but is it possible to count the number of syntax errors or get line numbers for all errors encountered? Or does this raise an exception on the first seen error?

add FSharp.Core as nuget package reference

from @dsyme comment

Mono Linux doesn't come with Profile 7/78/259 assemblies for FSharp.Core as yet (I've asked Xamarin to add them). You might need to add a nuget package reference to FSharp.Core to get those. That would be a good thing to add anyway

fslex emits: # 0 "" in output file -> breaks compilation

Hi,

Running fslex on an input file, it outputs

// Implementation file for parser generated by fsyacc
module Parser

nowarn "64";; // turn off warnings that type variables used in production annotations are instantiated to concrete type

open Microsoft.FSharp.Text.Lexing
open Microsoft.FSharp.Text.Parsing.ParseHelpers
#0 ""

....

The # 0 "" results in an error from the F# compiler "Unexpected integer literal in directive. Expected identifier or other token."

If I enter some text between the quotes, it compiles.

Emit tables for better diagnostics

The parsers we generate already have some tables for auto-generation of diagnostics

We should extend this to allow better diagnosis of error recovery situations.

Currently for a grammar like this:

nonterm1: 
    | tok1 { }  // ProdIdx 1
    | tok1 nonterm { }  // ProdIdx 2
    | tok2 nonterm { }  // ProdIdx 3
    
nonterm2: 
    | tok1 nonterm { }  // ProdIdx 4
    | tok2 nonterm { }  // ProdIdx 5

The parse will generate states something like this:

state 300:  
    nonterm1: . tok1 
    nonterm1: . tok1 nonterm 

state 301: 
    nonterm1: tok1 .
    nonterm1: tok1 . nonterm  

etc and we emit tables that contain this kind of information:

State --> ProdIdx list ( 300 --> [1; 2], 301 --> [1,2], ....)

ProdIdx --> NonTerm (1 --> nonterm1, 2 --> nonterm1, ...)

For diagnostics we really want textual representations of the states and productions, e.g. tables for:

ProdIdx --> text

   1 --> "tok1 nonterm (line 506 ilpars.fsy)"

State --> text

     301 --> 
         "nonterm1: . tok1 (rule at line 506 ilpars.fsy)
           nonterm1: . tok1 nonterm (rule at line 507 ilpars.fsy)"
     302 --> 
         "nonterm1: tok1 . (rule at line 506 ilpars.fsy)
           nonterm1: tok1 . nonterm (rule at line 507 ilpars.fsy)"

etc.

This information should probably just always be emitted by default - the slight increase in size is of no great concern in modern situations

Case insensitive option

Description

FsLexYacc would idealy need a command line option to specify the lexer to be built in case insensitive mode, as flex did allowed :

`-i'
instructs flex to generate a case-insensitive scanner. The case of letters given in the flex input patterns will be ignored, and tokens in the input will be matched regardless of case. The matched text given in yytext

It seems alternatively one could specify the option with "%option caseless" in the lexer input but I haven't find the reference in the documentation of flex.

Alternative workaround would be to support a way with regex to support insensitive match, it seems Lex had the option (with something like "(?i:word)"), but once again, apart from some comments on stackoverflow, I could not find the information in the docs

Expected behavior

Lexer recognize token, not taking in account the case of each characters.

Actual behavior

No option seems provided, not sure event if it would be supported with current regex implementation.

Known workarounds

Change the lexer to account for every possible combination uppercase/lowercase of each characters part of each tokens ! (very tedious !)

Related information

http://dinosaur.compilertools.net/flex/flex_17.html#SEC17
https://stackoverflow.com/questions/22686117/lex-case-insensitive-word-detection

Support for line start in regular expression

I'm using this project to create a static analysis tool for VBA (https://github.com/rixatron/vbacop) and I'm having some trouble with pre-processor directives which require the '#' to the be first the first character on the line. As far as I can see this isn't currently supported but I can't see a way to do without having support for detecting a new line in the regular expressions.

I'm happy to do the work myself to add this but I'm not sure how I'd go about implementing such a thing. Any help would be greatly appreciated.

Issue with running fsyacc with -v flag

When run with -v flag, like this
fsyacc.exe -v --module ExprPar ExprPar.fsy
fsyacc generates empty ExprPar.fsyacc.output file, and following error message

building tables
computing first function...        time: 00:00:00.0454196
building kernels...        time: 00:00:00.0359272
building kernel table...        time: 00:00:00.0101401
computing lookahead relations...........................        time: 00:00:00.0167823
building lookahead table...        time: 00:00:00.0080491
building action table...        time: 00:00:00.0129263
        building goto table...        time: 00:00:00.0005048
        returning tables.
writing tables to log
.\packages\FsLexYacc.7.0.2\build\fsyacc.exe : FSYACC: error FSY000: Index was outside the bounds of the array.
At line:1 char:1
.\packages\FsLexYacc.7.0.2\build\fsyacc.exe -v --module ExprPar .\FsL ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     CategoryInfo          : NotSpecified: (FSYACC: error F...s of the array.:String) [], RemoteException
     FullyQualifiedErrorId : NativeCommandError

It should produce log file with description of parser as stack automaton. When run without -v flag, fsyacc correctly compiles *.fsy file and generates *.fs file with parser code.

Related information

Problem observed on Windows 10, running fsyacc from Visual Studio 2015, nuget package version FsLexYacc 7.0.2.

Suggestion for MSBuild docs

Description

I am finally getting around to automating fslex/yacc build after years of running it by hand on commandline. The docs on home page are useful but missing some key details. Suggest augmenting this page

http://fsprojects.github.io/FsLexYacc/fslex.html

Where page says: You must also add FsLex and FsYacc entries like this:, say WHERE those should go. I'm experimentally inserting into MSBuild syntax but all insertions have caused errors in project file structure. Apologies if this is obvious but I try to avoid touching msbuild and a quick sentence about where to insert would be super helpful

Using F# keywords for non terminal names does not compile

Description

Using F# keywords for non terminal names does not compile.

Repro steps

FsYacc:

%token HEAD

%type < unit list > start

%%

start : type { $1 }

type : { [] } 
	| HEAD type { ()::$2 }

Expected behavior

Compile and produce the parser.

Actual behavior

Log errors like this
$PROJ\lib\Parser.fs(195,107): error FS0010: Incomplete structured construct at or before this point in binding. Expected identifier or other token. [$PROJ\lib\lib.fsproj]
$PROJ\lib\Parser.fs(195,60): error FS0583: Unmatched '(' [$PROJ\lib\lib.fsproj]
$PROJ\lib\Parser.fs(195,22): error FS0583: Unmatched '(' [$PROJ\lib\lib.fsproj]
$PROJ\lib\Parser.fs(195,107): error FS0010: Unexpected keyword 'type' in binding. Expected incomplete structured construct at or before this point or other token. [$PROJ\lib\lib.fsproj]
$PROJ\lib\Parser.fs(195,13): error FS3118: Incomplete value or function definition. If this is in an expression, the body of the expression
must be indented to the same column as the 'let' keyword. [$PROJ\lib\lib.fsproj]
$PROJ\lib\Parser.fs(195,13): error FS0588: The block following this 'let' is unfinished. Every code block is an expression and must have a result. 'let' cannot be the final code element in a block. Consider giving this block an explicit result. [$PROJ\lib\lib.fsproj]
$PROJ\lib\Parser.fs(195,112): error FS0010: Unexpected symbol ')' in binding. Expected '|]' or other token. [$PROJ\lib\lib.fsproj]
$PROJ\lib\Parser.fs(183,33): error FS0603: Unmatched '[|' [$PROJ\lib\lib.fsproj]
$PROJ\lib\Parser.fsy(33,32): error FS0010: Unexpected symbol ')' in definition. Expected incomplete structured construct at or before this point or other token. [$PROJ\lib\lib.fsproj]

with such code generated:

let _1 = (let data = parseState.GetInput(1) in (Microsoft.FSharp.Core.Operators.unbox data : 'type)) in

Known workarounds

Renaming the non terminal names to avoid keywords, e.g., type -> typ.

Related information

  • OS: Win 10 10.0.19041 N/A Build 19041
  • Branch: master
  • .NET Runtime, CoreCLR or Mono Version: CoreCLR 3.1.403

Reductions table being recreated on each parser invocation

It looks like the reductions table is now created lazily, to reduce startup cost. But after creation it is not saved in any way (lazy is not used).

e.g.

let tables () : Internal.Utilities.Text.Parsing.Tables<_> = 
  { reductions= _fsyacc_reductions ();
    endOfInputTag = _fsyacc_endOfInputTag;
    ... }
let ilInstrs lexer lexbuf : ILInstr array = Microsoft.FSharp.Core.Operators.unbox ((tables ()).Interpret(lexer, lexbuf, 0))

We should probably save the table after creation.

FsLexYacc needs a logo

FsLexYacc definitely needs a logo. I can propose simple option:
Option 1:
image
What else can be painted on the logo? Any ideas?

FSharp.Core Dependency

FsLexYacc 9.0.2 added a new FSharp.Core dependency (>= 4.3.4 && < 4.4.0)
The constraint < 4.4.0 is causing some difficulty when using with other packages

FsLexYacc broken under .net 5.0 runtime only

Description

Building a project (using nuget FsLexYacc 10.0.0) targeting .net 5.0 and with only .net sdk 5.0 installed is not possible. Here is a log from a build:

  It was not possible to find any compatible framework version
  The framework 'Microsoft.NETCore.App', version '3.0.0' was not found.
    - The following frameworks were found:
        5.0.0 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  
  You can resolve the problem by installing the specified framework and/or SDK.
  
  The specified framework can be found at:
    - https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=3.0.0&arch=x64&rid=osx.10.15-x64
/Users/pierre/.nuget/packages/fslexyacc/10.0.0/build/FsLexYacc.targets(43,3): error MSB3073: The command "dotnet "/Users/pierre/.nuget/packages/fslexyacc/10.0.0/build//fslex/netcoreapp3.0/fslex.dll"  -o "Lexer.fs" --module Expr.Lexer --unicode Lexer.fsl" exited with code 150.

Looks like tools are configured to run under .net 3 only.

Repro steps

Remove previously installed .net sdk and only install .net 5.0:

dotnet --list-sdks
> 5.0.100 [/usr/local/share/dotnet/sdk]

dotnet --list-runtimes
> Microsoft.AspNetCore.App 5.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
>Microsoft.NETCore.App 5.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  1. Step A

Convert a project to net5.0 (<TargetFramework>net5.0</TargetFramework>).
Build it ==> it fails.

Expected behavior

FsLex and FsYacc should still work under .net 5.0.

Actual behavior

It does not work under .net 5.0.

Known workarounds

Install runtime 3.x, but it's really ugly:

curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --channel 3.1 --install-dir /usr/share/dotnet

Related information

Tested on macOS, .net5.0 only, using FsLexYacc 10.0.0

Build fails with lots of errors under VsStudio Express 2013

Tried a clean build from the current github source on a newish installation of VS2013 express. I'm sure I'm missing some dependencies but it failed with a lot of errors below that didn't seem trivial. I also tried the command line build script which did pull a bunch of dependencies but failed with similar messages. I'm trying to migrate from the old Powerpack to this so I'd love to get it build. I've used FsLexYacc heavily in a genetic engineering language we use at Amyris so great to see this getting its own project

Darren

------ Build started: Project: FsLex, Configuration: Debug Any CPU ------
C:\extproj\FsLexYacc\lkg\FSharp.PowerPack-1.9.7.7\bin\FSharp.PowerPack.targets(32,3): error MSB4036: The "FsLex" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with in the project file, or in the *.tasks files located in the "C:\Program Files (x86)\MSBuild\12.0\bin" directory.
Done building project "FsLex.fsproj" -- FAILED.

Build FAILED.
------ Build started: Project: FsYacc, Configuration: Debug Any CPU ------
C:\extproj\FsLexYacc\lkg\FSharp.PowerPack-1.9.7.7\bin\FSharp.PowerPack.targets(32,3): error MSB4036: The "FsLex" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with in the project file, or in the *.tasks files located in the "C:\Program Files (x86)\MSBuild\12.0\bin" directory.
Done building project "FsYacc.fsproj" -- FAILED.

Build FAILED.
------ Build started: Project: FsLexYacc.Runtime, Configuration: Debug Any CPU ------
C:\Program Files (x86)\Microsoft SDKs\F#\3.1\Framework\v4.0\fsc.exe -o:obj\Debug\FsLexYacc.Runtime.dll -g --debug:full --noframework --doc:....\bin\Debug\FsLexYacc.Runtime.xml --optimize- --tailcalls- -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\FSharp.NETFramework\v4.0\4.3.0.0\FSharp.Core.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\mscorlib.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\System.Core.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\System.dll" --target:library --warn:3 --warnaserror:76 --vserrors --validate-type-providers --LCID:1033 --utf8output --fullpaths --flaterrors --highentropyva- --sqmsessionguid:fd20fb9f-26ce-4128-8b36-1dc1cdf9becd "C:\Users\daz\AppData\Local\Temp.NETFramework,Version=v4.0.AssemblyAttributes.fs" AssemblyInfo.fs ..\FsLexYacc.Runtime\Lexing.fsi ..\FsLexYacc.Runtime\Lexing.fs ..\FsLexYacc.Runtime\Parsing.fsi ..\FsLexYacc.Runtime\Parsing.fs
FsLexYacc.Runtime -> C:\extproj\FsLexYacc\bin\Debug\FsLexYacc.Runtime.dll
------ Build started: Project: FsLexYacc.Build.Tasks, Configuration: Debug Any CPU ------
C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(1635,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.Build.Utilities". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
C:\Program Files (x86)\Microsoft SDKs\F#\3.1\Framework\v4.0\fsc.exe -o:obj\Debug\FsLexYacc.Build.Tasks.dll -g --debug:full --noframework --doc:....\bin\Debug\FsLexYacc.Build.Tasks.xml --optimize- --tailcalls- -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\FSharp.NETFramework\v4.0\4.3.0.0\FSharp.Core.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\Microsoft.Build.Engine.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\Microsoft.Build.Framework.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\mscorlib.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\System.Core.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\System.dll" --target:library --warnaserror:76 --vserrors --validate-type-providers --LCID:1033 --utf8output --fullpaths --flaterrors --highentropyva- --sqmsessionguid:fd20fb9f-26ce-4128-8b36-1dc1cdf9becd "C:\Users\daz\AppData\Local\Temp.NETFramework,Version=v4.0.AssemblyAttributes.fs" AssemblyInfo.fs FsLex.Build.fs FsYacc.Build.fs
C:\extproj\FsLexYacc\src\FsLexYacc.Build.Tasks\FsLex.Build.fs(7,22): error FS0039: The namespace 'Utilities' is not defined
C:\extproj\FsLexYacc\src\FsLexYacc.Build.Tasks\FsLex.Build.fs(21,13): error FS0039: The type 'ToolTask' is not defined
C:\extproj\FsLexYacc\src\FsLexYacc.Build.Tasks\FsLex.Build.fs(21,13): error FS0039: The type 'ToolTask' is not defined
C:\extproj\FsLexYacc\src\FsLexYacc.Build.Tasks\FsLex.Build.fs(68,19): error FS0859: No abstract property was found that corresponds to this override
C:\extproj\FsLexYacc\src\FsLexYacc.Build.Tasks\FsLex.Build.fs(70,19): error FS0855: No abstract or interface member was found that corresponds to this override
C:\extproj\FsLexYacc\src\FsLexYacc.Build.Tasks\FsLex.Build.fs(73,19): error FS0855: No abstract or interface member was found that corresponds to this override
C:\extproj\FsLexYacc\src\FsLexYacc.Build.Tasks\FsLex.Build.fs(21,13): error FS0039: The type 'ToolTask' is not defined
C:\extproj\FsLexYacc\src\FsLexYacc.Build.Tasks\FsYacc.Build.fs(7,22): error FS0039: The namespace 'Utilities' is not defined
C:\extproj\FsLexYacc\src\FsLexYacc.Build.Tasks\FsYacc.Build.fs(14,13): error FS0039: The type 'ToolTask' is not defined
C:\extproj\FsLexYacc\src\FsLexYacc.Build.Tasks\FsYacc.Build.fs(14,13): error FS0039: The type 'ToolTask' is not defined
C:\extproj\FsLexYacc\src\FsLexYacc.Build.Tasks\FsYacc.Build.fs(74,19): error FS0859: No abstract property was found that corresponds to this override
C:\extproj\FsLexYacc\src\FsLexYacc.Build.Tasks\FsYacc.Build.fs(76,19): error FS0855: No abstract or interface member was found that corresponds to this override
C:\extproj\FsLexYacc\src\FsLexYacc.Build.Tasks\FsYacc.Build.fs(79,19): error FS0855: No abstract or interface member was found that corresponds to this override
C:\extproj\FsLexYacc\src\FsLexYacc.Build.Tasks\FsYacc.Build.fs(14,13): error FS0039: The type 'ToolTask' is not defined
Done building project "FsLexYacc.Build.Tasks.fsproj" -- FAILED.

Build FAILED.
------ Build started: Project: FsLexYacc.Tests, Configuration: Debug Any CPU ------
"C:\extproj\FsLexYacc.nuget\NuGet.exe" install "C:\extproj\FsLexYacc\tests\FsLexYacc.Tests\packages.config" -source "" -NonInteractive -RequireConsent -solutionDir "C:\extproj\FsLexYacc\ "
Restoring NuGet packages...
To prevent NuGet from downloading packages during build, open the Visual Studio Options dialog, click on the Package Manager node and uncheck 'Allow NuGet to download missing packages'.
All packages listed in packages.config are already installed.
Done building project "FsLex.fsproj" -- FAILED.
Done building project "FsYacc.fsproj" -- FAILED.
Done building project "FsLexYacc.Build.Tasks.fsproj" -- FAILED.
Done building project "FsLex.fsproj" -- FAILED.
Done building project "FsYacc.fsproj" -- FAILED.
Done building project "FsLexYacc.Build.Tasks.fsproj" -- FAILED.
C:\Program Files (x86)\Microsoft SDKs\F#\3.1\Framework\v4.0\fsc.exe -o:obj\Debug\FsLexYacc.Tests.dll -g --debug:full --noframework --define:DEBUG --define:TRACE --doc:bin\Debug\FsLexYacc.Tests.XML --optimize- --tailcalls- -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\FSharp.NETFramework\v4.0\4.3.0.0\FSharp.Core.dll" -r:C:\extproj\FsLexYacc\bin\Debug\fslex.exe -r:C:\extproj\FsLexYacc\bin\Debug\FsLexYacc.Build.Tasks.dll -r:C:\extproj\FsLexYacc\bin\Debug\FsLexYacc.Runtime.dll -r:C:\extproj\FsLexYacc\bin\Debug\fsyacc.exe -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\mscorlib.dll" -r:C:\extproj\FsLexYacc\packages\NUnit.2.6.3\lib\nunit.framework.dll -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\System.Core.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\System.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\System.Numerics.dll" --target:library --warn:3 --warnaserror:76 --vserrors --validate-type-providers --LCID:1033 --utf8output --fullpaths --flaterrors --highentropyva- --sqmsessionguid:fd20fb9f-26ce-4128-8b36-1dc1cdf9becd "C:\Users\daz\AppData\Local\Temp.NETFramework,Version=v4.0.AssemblyAttributes.fs" Tests.fs
FSC: error FS0084: Assembly reference 'C:\extproj\FsLexYacc\bin\Debug\fslex.exe' was not found or is invalid
FSC: error FS0084: Assembly reference 'C:\extproj\FsLexYacc\bin\Debug\FsLexYacc.Build.Tasks.dll' was not found or is invalid
FSC: error FS0084: Assembly reference 'C:\extproj\FsLexYacc\bin\Debug\fsyacc.exe' was not found or is invalid
Done building project "FsLexYacc.Tests.fsproj" -- FAILED.

Build FAILED.
========== Build: 1 succeeded or up-to-date, 4 failed, 0 skipped ==========

Tests/MiniProject : incorrect Import in .fsproj

The last line of .fsproj file (Import Project="....\bin\Debug\FsLexYacc.targets")
refers to Debug directory.
But "PM > Install-Package FsLexYacc" from VS 2013 Community which runs successfully only creates files in packages directory under the project directory.
I followed these steps
1/ Create a F# console app named "LexAndYaccMiniProject"
2/ Install package
3/ Close solution
4/ Copy all the files (Lexer.fsl, Parser.fsy,Program.fs,LexAndYaccMiniProject.fsproj,App.config) from github to local project directory
5/Open solution
--> Error Message saying there is no such "bin\Debug\FsLexYacc.targets" file.
Thanks for helping me. What did I do wrong and what should I check ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.