sly 3.3.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package sly --version 3.3.4                
NuGet\Install-Package sly -Version 3.3.4                
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="sly" Version="3.3.4" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add sly --version 3.3.4                
#r "nuget: sly, 3.3.4"                
#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 sly as a Cake Addin
#addin nuget:?package=sly&version=3.3.4

// Install sly as a Cake Tool
#tool nuget:?package=sly&version=3.3.4                

C# lex and yacc

Coverage Status .NET Core FOSSA Status

Open in GitHub Codespaces

License: MIT NuGet

Csly is inspired by the Python lex yacc library (PLY) and aims to simplify generating lexer/parsers in C#.

Getting started

If you'd like to get coding right away, read the quick getting-started guide, which will guide you through the implementation of a basic parser.

Documentation and examples

Complete documentation can be found in the wiki. For a list of more advanced samples check out the samples folder in the repo.

Csly special features

Csly is packed with special features that make it simpler to use, maintainable, and type-safe.

Fully embeddable

Csly has been designed to avoid extra build steps. Parser generators often need a build-time step to generate target language source code. That is not the case with csly. A simple Nuget command will configure csly for use in a 100% .NET implementation.

Csly does not need a build-time step, simplifying the build/CI process

Compact lexer/parser definition

The csly lexer/parser is defined with only 2 types:

  • a C# enum for the lexer,
  • a C# class for the parser.

Lexeme and parser production rules are defined using C# custom attributes making your code compact and readable. Although these features already exist with parser combinators (like Sprache or Eto.Parse), csly can use productions rules defined using either BNF or EBNF notation, which I think is more natural and easier to understand, assuring maintainability.

Define languages in a very compact and dependency-free way

See Lexer for lexers definition and BNF or EBNF for parser definitions.

Fully and Strictly typed

Csly is strictly typed, so every parser you define renders according to its input and output types. For additional details on parser typing, head to the parser definition section.

Be more confident that your parser will generate valid inputs and outputs.

Expression parsing

Many domain-specific languages need parsing expressions (boolean or numeric). A recursive-descent parser is hard to maintain when parsing expressions have multiple precedence levels. For that reason, csly offers a way to generate expression-parsing rules using only operator tokens and a simple-to-understand precedence scheme. Csly will then generate production rules to parse expressions, managing precedence and either left-or-right associativity.

Avoid burdensome hand-made expression parser implementations.

see expression parsing

Indentable languages support

Some languages use indentation to denote functional blocks, like Python or Yaml. Csly provides native support for indentation. Head to Indented Languages

Easily use indentation to make your language more readable.

Preserve comments

Comments or whitespace are almost every time discardable. But sometimes it makes sens to preserve them :

  • use comments to generate auto doc (think javadoc, c#'s xmldoc or python's docstring )
  • introduce meta data without cluttering your grammar

So CSLY borrowed the (antlr channel concept)[https://datacadamia.com/antlr/channel]. Every lexeme can be redirected to a specific channel. By default comments go to channel 2.

This feature is already available on branch dev but not deployed in any nuget package. Documentation is also a work in progress event though you can have it a glance looking at (EBNF unit tests)[https://github.com/b3b00/csly/blob/dev/ParserTests/EBNFTests.cs] :

Generic lexer

Lexemes are often similar from one language to another. Csly introduces a generic lexer that defines common lexemes and which can be reused across languages. The built-in generic lexer has better performance than a regex-based lexer.

Reuse common token definition and take advantage of better lexer performance.

See Generic lexer for the generic lexer implementation and Lexer for a general presentation on rolling your own.

What Csly is and isn't

Csly is not

Csly is not a fully-featured parser generator like ANTLR. You should therefore not use it to define strong-typed languages like C# or Java.

Csly is

Csly is perfect for small domain-specific languages (DSLs) that can be bundled in C# applications for end-users to interact with your application using natural language, for example.

Installation

Install from the NuGet gallery GUI or with the Package Manager Console using the following command:

Install-Package sly

or with dotnet core

dotnet add package sly

Special thanks to

<a href="https://jb.gg/OpenSource"><img height="200" src="src/logos/jetbrains-variant-2.svg"><a>

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  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 is compatible.  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 is compatible. 
.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 sly:

Package Downloads
CoreLisp

.net core lisp interpreter

formulae

Package Description

LuckyFish.Json

Package Description

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on sly:

Repository Stars
b3b00/csly
a C# embeddable lexer and parser generator (.Net core)
Version Downloads Last updated
3.5.0-alpha6 110 9/13/2024
3.5.0-alpha5 89 9/12/2024
3.5.0-alpha4 96 9/11/2024
3.5.0-alpha3 96 9/11/2024
3.5.0-alpha2 97 9/11/2024
3.5.0-alpha1 97 9/10/2024
3.4.6 107 11/8/2024
3.4.5 176 11/6/2024
3.4.4 96 11/5/2024
3.4.3 71 11/4/2024
3.4.2 81 11/3/2024
3.4.1 68 11/1/2024
3.4.1-alpha1 74 10/29/2024
3.4.0 124 10/26/2024
3.3.5 315 10/15/2024
3.3.4 84 10/14/2024
3.3.3 77 10/14/2024
3.3.2 79 10/14/2024
3.3.1 118 10/11/2024
3.3.0 129 10/10/2024
3.2.9 1,254 8/23/2024
3.2.9-alpha1 112 8/23/2024
3.2.8 1,809 7/19/2024
3.2.7 178 7/17/2024
3.2.6 120 7/16/2024
3.2.5 98 7/16/2024
3.2.4 107 7/16/2024
3.2.3 173 7/11/2024
3.2.2 126 7/8/2024
3.2.1 115 7/5/2024
3.2.0 128 7/3/2024
3.1.9 118 7/3/2024
3.1.8 136 7/3/2024
3.1.8-alpha3 115 7/2/2024
3.1.8-alpha2 93 7/2/2024
3.1.8-alpha1 117 7/2/2024
3.1.7 328 6/13/2024
3.1.6 392 5/29/2024
3.1.5 479 5/10/2024
3.1.4 257 5/2/2024
3.1.3 127 4/30/2024
3.1.2 109 4/29/2024
3.1.1 117 4/26/2024
3.1.0 456 4/19/2024
3.0.1 762 4/17/2024
3.0.0 117 4/17/2024
2.9.9 1,649 4/8/2024
2.9.8 4,854 1/5/2024
2.9.7.1 457 12/2/2023
2.9.7 3,251 10/19/2023
2.9.6.1 7,153 8/16/2023
2.9.6 170 8/16/2023
2.9.5.1 246 8/9/2023
2.9.5 169 8/8/2023
2.9.4.7 2,772 5/29/2023
2.9.4.6 4,381 3/31/2023
2.9.4.6-alpha 204 3/29/2023
2.9.4.5 4,257 3/13/2023
2.9.4.4 587 2/21/2023
2.9.4.3 794 2/12/2023
2.9.4.2 275 2/12/2023
2.9.4.2-alpha3 172 2/7/2023
2.9.4.2-alpha2 170 2/7/2023
2.9.4.2-alpha 258 1/31/2023
2.9.4.1 386 1/30/2023
2.9.4 447 1/12/2023
2.9.3.1 1,402 12/30/2022
2.9.3 941 12/7/2022
2.9.2.2 491 11/23/2022
2.9.2.1 527 11/9/2022
2.9.2 512 11/2/2022
2.9.1.1 681 10/17/2022
2.9.1 1,353 9/12/2022
2.9.0.9 1,329 9/4/2022
2.9.0.8 441 9/2/2022
2.9.0.7 455 9/1/2022
2.9.0.6 509 8/31/2022
2.9.0.5 3,928 8/8/2022
2.9.0.4 599 7/3/2022
2.9.0.3 524 7/1/2022
2.9.0.2 660 6/29/2022
2.9.0.1 476 6/29/2022
2.9.0 534 6/28/2022
2.8.0.5 5,580 3/22/2022
2.8.0.4-alpha 221 1/26/2022
2.8.0.3 20,162 12/11/2021
2.8.0.2 1,050 12/1/2021
2.8.0.1 904 12/1/2021
2.8.0 5,498 11/24/2021
2.8.0-alpha 6,006 11/24/2021
2.7.0.5 411 11/5/2021
2.7.0.4 352 11/5/2021
2.7.0.4-alpha.2 192 8/16/2021
2.7.0.4-alpha 252 8/16/2021
2.7.0.3 2,126 6/16/2021
2.7.0.2 464 6/14/2021
2.7.0.1 438 6/1/2021
2.7.0 11,303 5/11/2021
2.7.0-alpha 334 11/30/2020
2.6.4.2 1,117 4/15/2021
2.6.4.1 1,053 3/3/2021
2.6.4 512 2/22/2021
2.6.4-beta 248 2/22/2021
2.6.4-bea 259 2/22/2021
2.6.3.1 588 1/2/2021
2.6.3 558 11/23/2020
2.6.2.2 531 11/16/2020
2.6.2.1 556 11/7/2020
2.6.2 459 11/6/2020
2.6.1 3,194 10/5/2020
2.6.0.6 561 10/5/2020
2.6.0.5 846 9/4/2020
2.6.0.4 540 8/24/2020
2.6.0.3 586 8/4/2020
2.6.0.2 580 8/3/2020
2.6.0.1 1,176 6/12/2020
2.6.0 597 5/26/2020
2.5.0.1 1,790 4/21/2020
2.5.0 567 4/15/2020
2.4.2 2,246 2/21/2020
2.4.1.6 610 2/17/2020
2.4.1.5 677 1/28/2020
2.4.1.4 666 1/3/2020
2.4.1.3 610 1/2/2020
2.4.1.2 612 1/2/2020
2.4.1.1 608 12/17/2019
2.4.1 613 11/27/2019
2.4.0.6 600 11/21/2019
2.4.0.5 578 11/20/2019
2.4.0.4 592 11/18/2019
2.4.0.3 2,006 6/14/2019
2.4.0.1 671 6/14/2019
2.4.0 651 6/13/2019
2.3.0.1 757 5/15/2019
2.3.0 686 5/15/2019
2.2.5.3 757 3/22/2019
2.2.5.2 718 3/8/2019
2.2.5.1 1,715 12/27/2018
2.2.5 710 12/24/2018
2.2.4 756 12/4/2018
2.2.3 814 10/26/2018
2.2.2 819 9/21/2018
2.2.1 959 8/9/2018
2.2.0 959 7/25/2018
2.1.3 1,047 6/18/2018
2.1.2 1,056 6/10/2018
2.1.1 1,023 5/21/2018
2.1.0 1,054 5/14/2018
2.0.7 1,242 3/8/2018
2.0.6.2 1,035 3/6/2018
2.0.3 1,090 12/12/2017
2.0.2 1,001 11/30/2017
2.0.1 989 11/11/2017
1.3.5 996 10/30/2017
1.3.1 965 10/26/2017
1.0.4 1,289 6/16/2017