Technologies
Back
Software Development & Open Source

How I moved lexer construction to compile-time

Habr
Advertisement468 × 90
How I moved lexer construction to compile-time

The author shares their experience optimizing the lexer development process for HydraScript using .NET source generators. Previously, the process required manual copying of regular expressions, which was cumbersome and error-prone. The main challenge was the need to pass the output of one generator to another that uses the [GeneratedRegex] attribute. To solve this, the author conducted a deep dive into the Roslyn mechanism to correctly configure the order of code generator execution. As a result, the lexer build process was fully automated by moving it to the compilation stage. This allows tokens to be defined once, eliminating the need for manual code updates. The article is useful for developers working with Roslyn and code generation in .NET, as it reveals the nuances of coordinating multiple generators within a single project.

This is a summary. Read the full article at the original source:

Habr
Advertisement468 × 90
Share
Software Development & Open Source

Related stories

Advertisement970 × 250