Extending C# through ANTLR and the DLR

418 Views Asked by At

I'm currently in the process of writing a programming language which extends C# mainly by adding custom operators and keywords.

I have found the grammar file for c# 4 in http://antlrcsharp.codeplex.com/ but cannot find any examples on how to import this file in my own grammar file.

Can anyone provide some examples or point me to other projects which archive the same thing?

2

There are 2 best solutions below

0
On BEST ANSWER

If you want to extend c# that means you're doing a DSL?

Check this one out Irony from codeplex, Hanselman explains it better

0
On

Starting with ANTLR 3.1 there is a grammar composition feature. You can import other grammars to yours and then use and/or override rules from the imported ones.

Another approach would be to modify the existing C# grammar to your needs.