I am trying to do some homework with fsyacc, the Yacc parser generator used for F#.
When I run
mono fsyacc.exe --module Stmt Stmt.fsy
on the current folder that has the file Stmt.fsy and fsyacc.exe, I got this error message:
Unhandled Exception:
System.IO.FileNotFoundException: Could not load file or assembly 'FSharp.Core, Version=4.4.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies
But I do have FSharp.Core.4.3.4/ on my current folder.
FYI, I am testing on an Mac OS X if that matters. I installed FsLexYacc via nuget:
nuget install FsLexYacc
and then I made a symbolic link of fsyacc.exe to the current folder.
What is the right command line to parse on Mac, using fsyacc? I am working on an MacOS.
The instructions are not very clear in the documentation. You need the binaries of the tools, which you can build as follows:
git clone https://github.com/fsprojects/FsLexYacc.git
then build it from the command line
/build.sh
The tools are in FsLexx and FsYacc respectively. To run them you do:
dotnet fslex.dll inputfile -o outputfile
dotnet fsyacc.dll inputfile -o outputfile
but more simply you can run one of the samples e.g. LexAndYaccMiniProject. When you build it (e.g. in Visual Studio) you can see that behind the scenes it runs the tools and generates the parsers. Have a look at the project file to see how this is done.
Now you can create your own project by copying this sample.
Sidenote: You don't need Mono. FsLexYacc runs in .NET core.
Related
I use ninja as the build tool of cmake, ninja build parallelly. When build in the physical machine, it compiles without any problem, but in a Windows docker container, it reports:
fatal error C1041: cannot open program database 'blabla.pdb'; if multiple CL.EXE write to
the same .PDB file, please use /FS
The compiler is MSVC 2015, but the /FS seems a 2012 or 2013 option, after add /FS to the CXX flags:
The C++ compiler
"C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe"
is not able to compile a simple test program.
It compiles without problem if I just use one core.
I have searched the web for a long time, but no useful information found.
I'm trying to use F# with VS Code (v1.17.2) on MacOS (Sierra 10.12.6)
I think i've installed latest versions of Mono and .NET SDK
I'm trying just to build the simple project described here as a test
https://github.com/s952163/FSharpVSCode
after my default installation, I could do a MSBuild and run the program in the terminal without any problem. However at that stage,
(1) Intellisense is not working properly, not recognizing Deedle
(2) in the F# explorer it would say
'TestProject1.fsproj (load failed)
when doing a right-click i got this error
Error: MSBuild failed with exitCode 1 Working Directory:
'/Users/francois-guillaume.rideau/Documents/FsharpVsCode/TestProject1'
Exe Path: 'dotnet' Args: 'msbuild
/Users/francois-guillaume.rideau/Documents/FsharpVsCode/TestProject1/TestProject1.fsproj
/p:SkipCompilerExecution=true /p:ProvideCommandLineArgs=true
/p:CopyBuildOutputToOutputDirectory=false
/p:UseCommonOutputDirectory=true /t:_Inspect_FscArgs
/p:_Inspect_FscArgs_OutFile=/var/folders/gm/z065gk616xg6g0xgn4c7_bvc0000gn/T/tmp52c377ed.tmp.FscArgs.txt
/p:DesignTimeBuild=true /t:_Inspect_GetResolvedProjectReferences
/p:_Inspect_GetResolvedProjectReferences_OutFile=/var/folders/gm/z065gk616xg6g0xgn4c7_bvc0000gn/T/tmpfe4a2c2.tmp.GetResolvedProjectReferences.txt
/t:_Inspect_GetProperties
/p:_Inspect_GetProperties_OutFile=/var/folders/gm/z065gk616xg6g0xgn4c7_bvc0000gn/T/tmpfe4a2c2.tmp.GetProperties.txt
/nologo /verbosity:quiet' Log: writing helper target file in
'/Users/francois-guillaume.rideau/Documents/FsharpVsCode/TestProject1/obj/TestProject1.fsproj.proj-info.targets'
/usr/local/share/dotnet/sdk/2.0.2/Microsoft.Common.CurrentVersion.targets(1122,5):
error MSB3644: The reference assemblies for framework
".NETFramework,Version=v4.6.1" were not found. To resolve this,
install the SDK or Targeting Pack for this framework version or
retarget your application to a version of the framework for which you
have the SDK or Targeting Pack installed. Note that assemblies will be
resolved from the Global Assembly Cache (GAC) and will be used in
place of reference assemblies. Therefore your assembly may not be
correctly targeted for the framework you intend.
[/Users/francois-guillaume.rideau/Documents/FsharpVsCode/TestProject1/TestProject1.fsproj]
to try to solve this, i typed in the following
export FrameworkPathOverride=/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5/
but worse, after that, the project doesn't build anymore in VS Code as I get this output when trying (Cmd-Shift-P) MSBuild: Build Project
/usr/local/share/dotnet/sdk/2.0.2/Microsoft.Common.CurrentVersion.targets(1122,5): error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.6.1" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. [/Users/francois-guillaume.rideau/Documents/FsharpVsCode/TestProject1/TestProject1.fsproj]
screenshot here https://imgur.com/KtMM2Bu
VS Code environment is passed to msbuild when it invokes it, so setting environment variables on startup of VS Code does the trick:
FrameworkPathOverride=/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5/ code .
Go to project location in the terminal and then run FrameworkPathOverride=/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5/ code . as said before.
Then you should be able to build again.
I'm trying to find a simple solution that isn't so much manual work to reference packages. inside a .fsx file.
LinqPad 4 lets me simply add nuget packages
no intellisense or autocompletion
deletes package after download for certain types of packages (templatus for example)
LinqPad 5 beta lets me add nuget packages
deletes package after download for certain types of packages (templatus for example)
with frequent failures (intellisense and compilation)
VS2015 doesn't let you download/install packages for an fsx file (only into projects)
VSCode doesn't let you download/install nuget or paket packages for an fsx file.
So I wind up having to use .fsx in VS2015, while using linqpad to get packages downloaded (which still fails for packages like templatus where it downloads an exe not a dll). Then I have I can reference them as
#I #"..\LINQPad\NuGet.FW46\FParsec\FParsec.1.0.2\lib\net40-client\" // references AppData\local\ ... since . is %localappdata%\TEMP
doesn't match up with the relative pathing for intellisense/autocompletion engine in VSCode so I can't remove VS from the equation.
doesn't work outside of a machine that already has that package in that location
wind up doing a bunch of code that doesn't span .fsx files very well and has to be worked out per package reference
I don't want to create a project. I have a ton of individual scripts that are to be individually maintained and usable by others on-demand.
Is there an IDE (or fix/extension for one of these mentioned) that will give me intellisense, autocomplete, and package management for F# .fsx files that can work easily from user to user, machine to machine?
The Ionide plugins for VsCode and Atom have the functionality you're looking for
VsCode Instructions
Use the command palette to install the Ionide extensions ionide-fsharp and ionide-paket
You'll need to add your F# installation to your PATH
(on windows Rapid Enivornment Editor is my goto for PATH editing)
For F# 4.0 add C:\Program Files (x86)\Microsoft SDKs\F#\4.0\Framework\v4.0
Open the work folder that will hold your .fsx files
Executing paket commands through the command palette will be your primary interface for working with nuget packages
make a new .fsx file, (I recommend using the Advanced New File extension over the standard VsCode method)
The first step is to run paket init which is necessary to use paket to manage your packages
If you click the open button on the notification popups you can view the the output from paket in a side panel
After using the add nuget package command and entering extcorefor the package you should see the work tree
updated to
Then all you need to do is reference the package in the script and you'll get the auto-completion you're looking for
As of F# 5.0 you can now use the #r "nuget: Package" (ref):
#r "nuget: Newtonsoft.Json"
// Optionally, specify a version explicitly
// #r "nuget: Newtonsoft.Json,11.0.1"
open Newtonsoft.Json
let o = {| X = 2; Y = "Hello" |}
printfn "%s" (JsonConvert.SerializeObject o)
The log:
C:\WINDOWS\system32>luarocks install luasocket
Installing https://luarocks.org/luasocket-3.0rc1-2.src.rock...
Using https://luarocks.org/luasocket-3.0rc1-2.src.rock... switching to 'build' mode
cl /nologo /MD /O2 -c -Fosrc/mime.obj -Ic:/lua/include/ src/mime.c -DLUA_COMPAT_APIINTCASTS -DLUASOCKET_DEBUG -DNDEBUG -DLUASOCKET_API=__declspec(dllexport) -DMIME_API=__declspec(dllexport)
mime.c
src/mime.c(5): fatal error C1083: Cannot open include file: 'string.h': No such file or directory
Error: Build error: Failed compiling object src/mime.obj
I'm very new to the whole LuaRocks thing, so I have no idea how to go about fixing this.
Here's a non-complete guide to get you started on installing lua modules from a fresh Windows 7.
1) We need LuaRocks in order to install Lua dependencies automatically (similar to cpan/cpanm in Perl or pip in Python). Download LuaRocks by grabbing the latest version with a "-win32.zip" suffix from here: http://keplerproject.github.io/luarocks/releases/
At the time of this writing, this is the following file: http://keplerproject.github.io/luarocks/releases/luarocks-2.3.0-win32.zip
2) Unzip it into a new directory and install it with install.bat /L. Without the "/L" flag, it will complain that it cannot find your existing Lua installation. With the flag, it will just install a new Lua binary (version 5.1). LuaRocks is now installed to C:\Program Files (x86)\LuaRocks. You may now delete the extracted "luarocks-2.3.0-win32" directory.
3) In order to compile and install modules, we will need a C++ compiler. Download and install the Visual C++ Build Tools 2015 from here: http://landinghub.visualstudio.com/visual-cpp-build-tools
(We want this so that we can avoiding installing the huge, multi-gigabyte Visual Studio 2015.)
4) Navigate to C:\Program Files (x86)\Microsoft Visual C++ Build Tools. Right click on "Visual C++ 2015 x86 Native Build Tools Command Prompt", and select "Run as administrator".
5) Run the following command: "C:\Program Files (x86)\LuaRocks\luarocks.bat" install luasocket.
Note that you may have to install additional stuff for certain modules. And sometimes, modules are simply unable to be compiled on Windows at all.
After breaking out the troubled command :
/usr/jdk/jdk1.5.0_07/bin/java -Dant.home=. -cp $CLASSPATH:./build/classes org.apache.tools.ant.Main -emacs bootstrapI got the error:
BUILD FAILED
Could not load the version information
Before breaking out the above commad line I ran a complete ./build.sh and ./build install command and got:
Buildfile: build.xml
bootstrap:
prepare:
check_for_optional_packages:
build:
Created dir: /export/home/rs841k/tmp/apache-ant-1.6.0/build/lib
Compiling 233 source files to /export/home/rs841k/tmp/apache-ant-1.6.0/build/cla
sses
javac:
Does anyone have any idea what is happening here and how to resolve it?
This is happening: You're passing source and target parameters to javac. Source seems to be 1.5, and target 1.1. This is a combination that is not allowed. The compiler does not know how to build JVM-1.1-compatible byte code from your sources, which might use 1.5-specific features.
This Oracle article explains the details:
javac does not accept a target (or compilation strategy) lower than the source language it is configured to accept. Each new version of the source language is generally accompanied by a new ClassFile version that allows the ClassFile to give meaning to new bytecode instructions, flags, and attributes. Encoding new source language constructs in older ClassFile versions is likely to be difficult. How would javac encode annotations from the Java 1.5 source language without the Runtime[In]Visible[Parameter]Annotations attributes that appeared in the 49.0 ClassFile?