sly 3.1.5

dotnet add package sly --version 3.1.5
NuGet\Install-Package sly -Version 3.1.5
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.1.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add sly --version 3.1.5
#r "nuget: sly, 3.1.5"
#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.1.5

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

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.1.5 0 5/10/2024
3.1.4 115 5/2/2024
3.1.3 88 4/30/2024
3.1.2 78 4/29/2024
3.1.1 87 4/26/2024
3.1.0 292 4/19/2024
3.0.1 282 4/17/2024
3.0.0 78 4/17/2024
2.9.9 417 4/8/2024
2.9.8 2,981 1/5/2024
2.9.7.1 426 12/2/2023
2.9.7 2,198 10/19/2023
2.9.6.1 5,139 8/16/2023
2.9.6 136 8/16/2023
2.9.5.1 211 8/9/2023
2.9.5 138 8/8/2023
2.9.4.7 2,711 5/29/2023
2.9.4.6 3,511 3/31/2023
2.9.4.6-alpha 138 3/29/2023
2.9.4.5 4,223 3/13/2023
2.9.4.4 544 2/21/2023
2.9.4.3 511 2/12/2023
2.9.4.2 249 2/12/2023
2.9.4.2-alpha3 146 2/7/2023
2.9.4.2-alpha2 141 2/7/2023
2.9.4.2-alpha 217 1/31/2023
2.9.4.1 352 1/30/2023
2.9.4 411 1/12/2023
2.9.3.1 1,307 12/30/2022
2.9.3 893 12/7/2022
2.9.2.2 454 11/23/2022
2.9.2.1 490 11/9/2022
2.9.2 475 11/2/2022
2.9.1.1 648 10/17/2022
2.9.1 1,253 9/12/2022
2.9.0.9 1,266 9/4/2022
2.9.0.8 407 9/2/2022
2.9.0.7 426 9/1/2022
2.9.0.6 466 8/31/2022
2.9.0.5 3,398 8/8/2022
2.9.0.4 528 7/3/2022
2.9.0.3 493 7/1/2022
2.9.0.2 621 6/29/2022
2.9.0.1 447 6/29/2022
2.9.0 496 6/28/2022
2.8.0.5 5,500 3/22/2022
2.8.0.4-alpha 191 1/26/2022
2.8.0.3 14,060 12/11/2021
2.8.0.2 1,015 12/1/2021
2.8.0.1 874 12/1/2021
2.8.0 5,447 11/24/2021
2.8.0-alpha 5,984 11/24/2021
2.7.0.5 378 11/5/2021
2.7.0.4 317 11/5/2021
2.7.0.4-alpha.2 179 8/16/2021
2.7.0.4-alpha 228 8/16/2021
2.7.0.3 2,028 6/16/2021
2.7.0.2 429 6/14/2021
2.7.0.1 401 6/1/2021
2.7.0 9,832 5/11/2021
2.7.0-alpha 300 11/30/2020
2.6.4.2 1,049 4/15/2021
2.6.4.1 1,013 3/3/2021
2.6.4 481 2/22/2021
2.6.4-beta 220 2/22/2021
2.6.4-bea 229 2/22/2021
2.6.3.1 556 1/2/2021
2.6.3 529 11/23/2020
2.6.2.2 494 11/16/2020
2.6.2.1 521 11/7/2020
2.6.2 435 11/6/2020
2.6.1 3,099 10/5/2020
2.6.0.6 533 10/5/2020
2.6.0.5 820 9/4/2020
2.6.0.4 511 8/24/2020
2.6.0.3 540 8/4/2020
2.6.0.2 554 8/3/2020
2.6.0.1 1,065 6/12/2020
2.6.0 568 5/26/2020
2.5.0.1 1,697 4/21/2020
2.5.0 532 4/15/2020
2.4.2 2,188 2/21/2020
2.4.1.6 583 2/17/2020
2.4.1.5 644 1/28/2020
2.4.1.4 633 1/3/2020
2.4.1.3 581 1/2/2020
2.4.1.2 579 1/2/2020
2.4.1.1 574 12/17/2019
2.4.1 573 11/27/2019
2.4.0.6 567 11/21/2019
2.4.0.5 541 11/20/2019
2.4.0.4 560 11/18/2019
2.4.0.3 1,918 6/14/2019
2.4.0.1 640 6/14/2019
2.4.0 622 6/13/2019
2.3.0.1 722 5/15/2019
2.3.0 653 5/15/2019
2.2.5.3 725 3/22/2019
2.2.5.2 685 3/8/2019
2.2.5.1 1,626 12/27/2018
2.2.5 673 12/24/2018
2.2.4 724 12/4/2018
2.2.3 781 10/26/2018
2.2.2 783 9/21/2018
2.2.1 919 8/9/2018
2.2.0 932 7/25/2018
2.1.3 1,008 6/18/2018
2.1.2 1,026 6/10/2018
2.1.1 993 5/21/2018
2.1.0 1,011 5/14/2018
2.0.7 1,209 3/8/2018
2.0.6.2 1,006 3/6/2018
2.0.3 1,065 12/12/2017
2.0.2 970 11/30/2017
2.0.1 954 11/11/2017
1.3.5 959 10/30/2017
1.3.1 933 10/26/2017
1.0.4 1,247 6/16/2017