sly 3.7.3

dotnet add package sly --version 3.7.3
                    
NuGet\Install-Package sly -Version 3.7.3
                    
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.7.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="sly" Version="3.7.3" />
                    
Directory.Packages.props
<PackageReference Include="sly" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add sly --version 3.7.3
                    
#r "nuget: sly, 3.7.3"
                    
#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.
#addin nuget:?package=sly&version=3.7.3
                    
Install as a Cake Addin
#tool nuget:?package=sly&version=3.7.3
                    
Install as a Cake Tool

C# lex and yacc

Coverage Status Build FOSSA Status Quality gate

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

Buy me a coffee

If you found CSLY usefull consider supporting with :

"Buy Me A Coffee"

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 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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 (4)

Showing the top 4 NuGet packages that depend on sly:

Package Downloads
CoreLisp

.net core lisp interpreter

formulae

Package Description

ServeSharp.Core

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.7.3 706 4/25/2025
3.7.2 204 4/24/2025
3.7.1 245 4/15/2025
3.7.0 261 4/14/2025
3.6.4 227 4/10/2025
3.6.3 355 3/27/2025
3.6.2 565 3/25/2025
3.6.1 193 3/21/2025
3.6.0 219 3/19/2025
3.5.4 659 2/21/2025
3.5.3 719 2/18/2025
3.5.2 1,127 1/17/2025
3.5.1 562 12/29/2024
3.5.0 307 12/24/2024
3.5.0-alpha6 133 9/13/2024
3.5.0-alpha5 110 9/12/2024
3.5.0-alpha4 117 9/11/2024
3.5.0-alpha3 114 9/11/2024
3.5.0-alpha2 113 9/11/2024
3.5.0-alpha1 118 9/10/2024
3.4.9 177 12/18/2024
3.4.8 148 12/17/2024
3.4.7 841 12/13/2024
3.4.6 1,767 11/8/2024
3.4.5 536 11/6/2024
3.4.4 691 11/5/2024
3.4.3 122 11/4/2024
3.4.2 132 11/3/2024
3.4.1 129 11/1/2024
3.4.1-alpha1 106 10/29/2024
3.4.0 217 10/26/2024
3.3.5 574 10/15/2024
3.3.4 131 10/14/2024
3.3.3 128 10/14/2024
3.3.2 137 10/14/2024
3.3.1 164 10/11/2024
3.3.0 180 10/10/2024
3.2.9 2,974 8/23/2024
3.2.9-alpha1 136 8/23/2024
3.2.8 1,912 7/19/2024
3.2.7 281 7/17/2024
3.2.6 162 7/16/2024
3.2.5 142 7/16/2024
3.2.4 156 7/16/2024
3.2.3 218 7/11/2024
3.2.2 167 7/8/2024
3.2.1 153 7/5/2024
3.2.0 173 7/3/2024
3.1.9 155 7/3/2024
3.1.8 175 7/3/2024
3.1.8-alpha3 142 7/2/2024
3.1.8-alpha2 120 7/2/2024
3.1.8-alpha1 141 7/2/2024
3.1.7 377 6/13/2024
3.1.6 447 5/29/2024
3.1.5 523 5/10/2024
3.1.4 293 5/2/2024
3.1.3 159 4/30/2024
3.1.2 142 4/29/2024
3.1.1 152 4/26/2024
3.1.0 490 4/19/2024
3.0.1 811 4/17/2024
3.0.0 153 4/17/2024
2.9.9 3,232 4/8/2024
2.9.8 7,296 1/5/2024
2.9.7.1 485 12/2/2023
2.9.7 3,901 10/19/2023
2.9.6.1 10,646 8/16/2023
2.9.6 196 8/16/2023
2.9.5.1 279 8/9/2023
2.9.5 200 8/8/2023
2.9.4.7 2,832 5/29/2023
2.9.4.6 4,562 3/31/2023
2.9.4.6-alpha 238 3/29/2023
2.9.4.5 4,292 3/13/2023
2.9.4.4 632 2/21/2023
2.9.4.3 1,087 2/12/2023
2.9.4.2 317 2/12/2023
2.9.4.2-alpha3 206 2/7/2023
2.9.4.2-alpha2 203 2/7/2023
2.9.4.2-alpha 295 1/31/2023
2.9.4.1 422 1/30/2023
2.9.4 487 1/12/2023
2.9.3.1 1,451 12/30/2022
2.9.3 989 12/7/2022
2.9.2.2 540 11/23/2022
2.9.2.1 571 11/9/2022
2.9.2 550 11/2/2022
2.9.1.1 720 10/17/2022
2.9.1 1,547 9/12/2022
2.9.0.9 1,373 9/4/2022
2.9.0.8 489 9/2/2022
2.9.0.7 501 9/1/2022
2.9.0.6 553 8/31/2022
2.9.0.5 5,794 8/8/2022
2.9.0.4 643 7/3/2022
2.9.0.3 581 7/1/2022
2.9.0.2 704 6/29/2022
2.9.0.1 521 6/29/2022
2.9.0 583 6/28/2022
2.8.0.5 5,754 3/22/2022
2.8.0.4-alpha 278 1/26/2022
2.8.0.3 25,596 12/11/2021
2.8.0.2 1,108 12/1/2021
2.8.0.1 962 12/1/2021
2.8.0 5,578 11/24/2021
2.8.0-alpha 6,057 11/24/2021
2.7.0.5 465 11/5/2021
2.7.0.4 408 11/5/2021
2.7.0.4-alpha.2 243 8/16/2021
2.7.0.4-alpha 303 8/16/2021
2.7.0.3 2,309 6/16/2021
2.7.0.2 524 6/14/2021
2.7.0.1 493 6/1/2021
2.7.0 13,009 5/11/2021
2.7.0-alpha 394 11/30/2020
2.6.4.2 1,180 4/15/2021
2.6.4.1 1,120 3/3/2021
2.6.4 581 2/22/2021
2.6.4-beta 307 2/22/2021
2.6.4-bea 324 2/22/2021
2.6.3.1 653 1/2/2021
2.6.3 629 11/23/2020
2.6.2.2 606 11/16/2020
2.6.2.1 623 11/7/2020
2.6.2 533 11/6/2020
2.6.1 3,284 10/5/2020
2.6.0.6 630 10/5/2020
2.6.0.5 915 9/4/2020
2.6.0.4 605 8/24/2020
2.6.0.3 658 8/4/2020
2.6.0.2 652 8/3/2020
2.6.0.1 1,250 6/12/2020
2.6.0 678 5/26/2020
2.5.0.1 1,864 4/21/2020
2.5.0 644 4/15/2020
2.4.2 2,346 2/21/2020
2.4.1.6 688 2/17/2020
2.4.1.5 753 1/28/2020
2.4.1.4 739 1/3/2020
2.4.1.3 683 1/2/2020
2.4.1.2 686 1/2/2020
2.4.1.1 682 12/17/2019
2.4.1 688 11/27/2019
2.4.0.6 676 11/21/2019
2.4.0.5 659 11/20/2019
2.4.0.4 665 11/18/2019
2.4.0.3 2,083 6/14/2019
2.4.0.1 749 6/14/2019
2.4.0 727 6/13/2019
2.3.0.1 834 5/15/2019
2.3.0 766 5/15/2019
2.2.5.3 840 3/22/2019
2.2.5.2 805 3/8/2019
2.2.5.1 2,015 12/27/2018
2.2.5 789 12/24/2018
2.2.4 840 12/4/2018
2.2.3 917 10/26/2018
2.2.2 920 9/21/2018
2.2.1 1,067 8/9/2018
2.2.0 1,117 7/25/2018
2.1.3 1,284 6/18/2018
2.1.2 1,292 6/10/2018
2.1.1 1,262 5/21/2018
2.1.0 1,304 5/14/2018
2.0.7 1,416 3/8/2018
2.0.6.2 1,281 3/6/2018
2.0.3 1,341 12/12/2017
2.0.2 1,169 11/30/2017
2.0.1 1,165 11/11/2017
1.3.5 1,166 10/30/2017
1.3.1 1,137 10/26/2017
1.0.4 1,547 6/16/2017