FslexFsyacc.Bootstrap
1.5.4
dotnet add package FslexFsyacc.Bootstrap --version 1.5.4
NuGet\Install-Package FslexFsyacc.Bootstrap -Version 1.5.4
<PackageReference Include="FslexFsyacc.Bootstrap" Version="1.5.4" />
paket add FslexFsyacc.Bootstrap --version 1.5.4
#r "nuget: FslexFsyacc.Bootstrap, 1.5.4"
// Install FslexFsyacc.Bootstrap as a Cake Addin #addin nuget:?package=FslexFsyacc.Bootstrap&version=1.5.4 // Install FslexFsyacc.Bootstrap as a Cake Tool #tool nuget:?package=FslexFsyacc.Bootstrap&version=1.5.4
FslexFsyacc & Runtime
Tools and Runtime for Fslex/Fsyacc analyzer/parser generation tools.
Fslex is a code generator that uses regular expression syntax as a rule to generate a function, which divides the input token sequence into groups at a higher level. The Fslex is often used to remove redundant delimiters, add omitted delimiters or other syntax components, and so on. The Fslex is also used to determine context somewhere in the stream.
Fsyacc is a code generator that use BNF productions and precedences as a rule to generate a function, which resolves the input token sequence to an abstract syntax tree.
Fsyacc Example
Dragon book fig 4-59 example expr.fsyacc
, fsyacc input file:
%{
open Expr.ExprToken
%}
expr : expr "+" expr { s0 + s2 }
| expr "-" expr { s0 - s2 }
| expr "*" expr { s0 * s2 }
| expr "/" expr { s0 / s2 }
| "(" expr ")" { s1 }
| "-" expr %prec UMINUS { -s1 }
| NUMBER { s0 }
%%
%left "+" "-"
%left "*" "/"
%right UMINUS
%%
%type <float> NUMBER expr
After ParseTable
module is generated, you can use the parse function to work:
let inp = "2 + 3 * 5"
let y =
inp
|> ExprToken.tokenize
|> ExprParseTable.parse
Should.equal y 17.0
Fslex Example
The ch8.6 Some Recursive Descent Parsing in Expert F# 4.0, the fslex input file:
%{
open FslexFsyacc
open PolynomialExpressions.Tokenizer
type token = Position<Token>
%}
<index> = "**" INT
<sign> = [ "+" "-" ]
%%
<sign>? INT { // multiline test
toConst lexbuf }
<sign>? INT? ID <index>? { toTerm lexbuf }
After DFA
module is generated, you can use the split function to work:
let x = "2x**2+3x-5"
let y =
x
|> Tokenizer.tokenize
|> TermDFA.analyze
|> Seq.toList
Should.equal y [Term(2,"x",2);Term(3,"x",1);Const -5]
Why use this package?
You can use your existing handwriting tokenizer.
This package uses standard lex/yacc syntax to minimize your learning costs.
fslex/fsyacc generates respectively an independent, side-effect-free function that can be called flexibly.
The method of generating code is simple, without command lines and without the need to configure projects.
The result code is data-driven and highly readable.
Flexiblely compose of tokenize, regular expressions, BNF technology.
用正则表达式,BNF语法表达语言。
无限嵌套BNF和正则表达式。将一个大的BNF模块化多个小BNF。其好处包括降低语法难度,增加了可读性,减少记忆量。语法文件清晰,几乎可以直接作为帮助文档。避免许多手写代码。
Product | Versions 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. |
-
.NETStandard 2.0
- FSharp.Core (>= 8.0.301)
- FslexFsyacc (>= 1.5.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
head or last terminal