FSharpCompiler.Analyzing 1.1.0

Suggested Alternatives

FslexFsyacc

Additional Details

Replace this package with the FslexFsyacc package, which implements all the features of this package and is more friendly.

dotnet add package FSharpCompiler.Analyzing --version 1.1.0
NuGet\Install-Package FSharpCompiler.Analyzing -Version 1.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FSharpCompiler.Analyzing" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FSharpCompiler.Analyzing --version 1.1.0
#r "nuget: FSharpCompiler.Analyzing, 1.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install FSharpCompiler.Analyzing as a Cake Addin
#addin nuget:?package=FSharpCompiler.Analyzing&version=1.1.0

// Install FSharpCompiler.Analyzing as a Cake Tool
#tool nuget:?package=FSharpCompiler.Analyzing&version=1.1.0

FSharpCompiler.Analyzing is the runtime for lexical analyzer.

How to write a lexical analyzer, see this solution xp44mm/PolynomialExpressions, We just extract the usage of the runtime library.

first, Install runtime NuGet:

install-package fsharpcompiler.analyzing

You should have written by hand a DFA or automatically generate a DFA by Lex. The DFA is as follows.

module PolynomialExpressions.TermDFA
let dtran = set [ ... ]
let finalLexemes:(Set<uint32>*Set<uint32>) list = [ ... ]

dtran is state transition table. finalLexemes is a list, an element of which is final state and trailing context state of the pattern.

build lexical analyzer using DFA:

open FSharpCompiler.Analyzing
let analyzer = LexicalAnalyzer(TermDFA.dtran, TermDFA.finalLexemes)
let split (tokens:seq<Token>) = analyzer.split(tokens,getTag)

split will return a steam of matched info, which consists of the index of matched pattern, and its occurrence of tokens.

We can now test the split on some sample inputs:

let tokens = [INT 2;ID "x";HAT;INT 2;PLUS;INT 3;ID "x";PLUS;INT 5]
let y = tokens |> Driver.split |> Seq.toList
Should.equal y 
<| [1,[INT 2;ID "x";HAT;INT 2];1,[PLUS;INT 3;ID "x"];0,[PLUS;INT 5]]

The result is a sequence of binary tuples, the type of which is seq<int*token seq>, which consists of an int and an groupings of tokens. The former is the matched pattern, and latter is the matched occurrence.

The results of parsing are a generic data structure, and we translate it into more semantic data. for example:

let mapper = function
| 0, [      INT n] 
| 0, [PLUS ;INT n] ->  Const n
| 0, [MINUS;INT n] ->  Const -n

| 1, [      ID x] 
| 1, [PLUS ;ID x] -> Term(1,x,1)
| 1, [MINUS;ID x] -> Term(-1,x,1)
| 1, [      ID x;HAT;INT i] 
| 1, [PLUS ;ID x;HAT;INT i] -> Term(1,x,i)
| 1, [MINUS;ID x;HAT;INT i] -> Term(-1,x,i)

| 1, [      INT n;ID x] 
| 1, [PLUS ;INT n;ID x] -> Term(n,x,1)
| 1, [MINUS;INT n;ID x] -> Term(-n,x,1)
| 1, [      INT n;ID x;HAT;INT i] 
| 1, [PLUS ;INT n;ID x;HAT;INT i] -> Term(n,x,i)
| 1, [MINUS;INT n;ID x;HAT;INT i] -> Term(-n,x,i)

| _ -> failwith ""

let parse (tokens:seq<Token>) =
    tokens
    |> Driver.split
    |> Seq.map mapper
    |> Seq.toList

In the example above, parse combines all the functions together.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on FSharpCompiler.Analyzing:

Package Downloads
FSharpCompiler.Lex

Lex are tools for generating lexical analyzer.

FSharpCompiler.Yacc

Yacc utility for.NET platform. Yacc are tools for generating parsers.

FSharp.JLinq

`FSharp.JLinq` is a library to enhance JToken located in `Newtonsoft.Json.Linq`.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.0 3,177 8/21/2021
1.0.4 2,698 7/18/2021
1.0.3 4,690 3/13/2021
1.0.2 1,564 2/20/2021
1.0.1 1,196 1/24/2021
1.0.0 1,181 1/21/2021

dfa data api move to lex.