A General-Purpose Lexer and Parser for .NET

J

jehugaleahsa

Hello:

Before I venture down the dark alley of open source lexers and parsers
written in C#, I was wondering if .NET already had such a thing. I
think anyone with a basic understand of Regex and a little free time
could write an inefficient lexical analyzer.

I was surprised 3 months ago, after writing a C# writer, when I
learned about the System.CodeDom classes, which were not only way more
complete and flexible, but could build the code in C# or VB and could
build the code as a string or an assembly. It put me back in my
developer diapers. I'm still kicking myself for wasting all that time.

I want to make sure that .NET, in MS's infinite wisdom, didn't also
make a lexer/parser/compiler namespace. Lex and Yacc are great if your
creating a C/C++ program or are willing to call a native method. There
really needs to be equivilent tools for generating .NET code (C# or IL
preferrably) from a Backus Naur form. Especially when you plan on
doing the parsing at runtime within an application.

It has come to my attention lately that I need to create a simple
parser for one of my open source projects, for the sanity and
convenience of my users. I have been reading my Dragon book, but it
takes a lot of time to write your own compiler. I don't think I want
to completely reinvent the wheel here if there is already a superior
product out there that can generate the .NET code for me.

I'd be happy if someone could point me to a free, decent lexer/parser
that can generate an efficient RL parser written in C#. I've played
around with quite a few that can be found on CodePlex, but I have been
less than impressed. Application-specific languages are pretty common
these days, so I expect some of you have worked with them.

Thanks for any pointers,
Travis
 
J

jehugaleahsa

Here is a fairly well tested parser (written by me):http://sites.google.com/site/fredm/linguist-parsing-system

The documentation should let you know if it will serve your purpose.

MS seems to be writing a "compiler as a service" which has a very impressive
demo athttp://channel9.msdn.com/pdc2008/TL16/.  The whole talk is very good, but
if you want to hear about the above topic, scroll to about 60 minutes into
the talk.












- Show quoted text -

Woah!
 
J

jehugaleahsa

Here is a fairly well tested parser (written by me):http://sites.google.com/site/fredm/linguist-parsing-system

The documentation should let you know if it will serve your purpose.

MS seems to be writing a "compiler as a service" which has a very impressive
demo athttp://channel9.msdn.com/pdc2008/TL16/.  The whole talk is very good, but
if you want to hear about the above topic, scroll to about 60 minutes into
the talk.












- Show quoted text -

Woah!
 
P

Pavel Minaev

Before I venture down the dark alley of open source lexers and parsers
written in C#, I was wondering if .NET already had such a thing. I
think anyone with a basic understand of Regex and a little free time
could write an inefficient lexical analyzer.

I was surprised 3 months ago, after writing a C# writer, when I
learned about the System.CodeDom classes, which were not only way more
complete and flexible, but could build the code in C# or VB and could
build the code as a string or an assembly. It put me back in my
developer diapers. I'm still kicking myself for wasting all that time.

I want to make sure that .NET, in MS's infinite wisdom, didn't also
make a lexer/parser/compiler namespace. Lex and Yacc are great if your
creating a C/C++ program or are willing to call a native method. There
really needs to be equivilent tools for generating .NET code (C# or IL
preferrably) from a Backus Naur form. Especially when you plan on
doing the parsing at runtime within an application.

I'm not aware of any stock parsing solution in the Framework Class Library.

On the other hand, F# comes with fslex/fsyacc combo, which does what you'd
expect it to do from the names. But, of course, it's for F#.
 
P

Pavel Minaev

Before I venture down the dark alley of open source lexers and parsers
written in C#, I was wondering if .NET already had such a thing. I
think anyone with a basic understand of Regex and a little free time
could write an inefficient lexical analyzer.

I was surprised 3 months ago, after writing a C# writer, when I
learned about the System.CodeDom classes, which were not only way more
complete and flexible, but could build the code in C# or VB and could
build the code as a string or an assembly. It put me back in my
developer diapers. I'm still kicking myself for wasting all that time.

I want to make sure that .NET, in MS's infinite wisdom, didn't also
make a lexer/parser/compiler namespace. Lex and Yacc are great if your
creating a C/C++ program or are willing to call a native method. There
really needs to be equivilent tools for generating .NET code (C# or IL
preferrably) from a Backus Naur form. Especially when you plan on
doing the parsing at runtime within an application.

I'm not aware of any stock parsing solution in the Framework Class Library.

On the other hand, F# comes with fslex/fsyacc combo, which does what you'd
expect it to do from the names. But, of course, it's for F#.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top