"The noblest pleasure is the joy of understanding"   (Leonardo da Vinci)
Website banner

[C# Talk] : LALR(1) parser in C#

Always being interested in parsers, I decided to try my luck on writing an LALR(1) parser in C#. Traditionally these parsers (Yacc, Bison) have been written so that you must run the scanner/lexer first, then include the output into your project as separate files.

I decided it was smarter if everything was assembled into one Parser class, which you could then instantiate in your program. I wanted to be able to configure it via a grammar also based on objects, build it, and then run the parser every time I wanted to parse a text string.

This is similar to the way the Reges class in C# works. You compile your regex first by instantiating a Regex class and give it the regex pattern, thereafter you can use it to match text strings multiple times.

Read more here…

Leave a Reply

[[[ Copyright (C) Thor Asmund 1998-2008 ]]]