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:
HabrRelated stories
The author shares their personal experience in developing a custom state management library called "nexus-state." The article explores various approac…
Agentic AI for Mainframe Modernization: From COBOL Understanding to Automated Code Transformation
Mainframe modernization remains a complex challenge due to decades of accumulated business logic embedded in COBOL code. While generative AI has previ…
In this article, the author explores common challenges encountered when using mock objects in software unit testing. The author shares personal experi…



