Skip to content

Playing around with source generating parsers from attributes in C#

License

Notifications You must be signed in to change notification settings

will14smith/SourceGeneratedParsing

Repository files navigation

SourceGeneratedParsing

I hadn't seen any libraries generating parsers using C# Source Generators so I decided to give it a go

The example project has some examples of what is supported currently

Notes

  • Currently using a very basic lexing system, just tries to match a bunch of regexes sequentially until it hits the first match
  • Parser is a subset of a PEG Packrat parser, currently only predicates are not supported

Future stuff

  • Add predicate support to the parser, also supporting left recursion might be nice
  • Much better error handling in the source generator, currently if you step out of what's expected it'll explode with no warning, there are a couple of examples of using diagnostics that could be expanded
  • Making the lexer/tokentype concept optional, e.g. productions could reference chars/regex directly
  • Look at switching to an incremental source generator

About

Playing around with source generating parsers from attributes in C#

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages