Jens Nolte
Jens Nolte

Reputation: 509

Building a Compiler for a DSL using ANTLR and the Antlr CSharp Target

I'm in the job of writing a compiler which compiles a project-specific DSL (with the features of a basic scripting language) into an project-specific assembler language. The platform is written in C#, so a native .NET-Compiler would be the perfect solution.

I already did a lot of research and it seems ANTLR would fit in the job of building the compiler, in case I understand the following things right:

I have to write the Grammar-File and a "Template" which emits the assembler. The ANTLR-framework (java) generates a Compiler from the grammar file. The Compiler itself is pure C# (by using the Antlr 3 CSharp Target) and can, after compiling to an .NET assembly, compile "my" DSL to our custom assembler.

Am I getting the point? And is there definitively no need for Java / the ANTLR-Java-API at runtime (= when "using" the compiler)? (I'm also open for other solutions/frameworks, as long as the resulting compiler is a .NET component).

Thx :)

Upvotes: 2

Views: 1734

Answers (1)

Matthew Manela
Matthew Manela

Reputation: 16752

There is detailed information about using the CSHarp target for ANTLR

In summary:

All you need is the C# parser/lexer code that ANTLR generates in addition to a reference to the ntlr3.Runtime.dll.

The dll is a modeled after the Java version but doesn't use or call into anything that is Java.

Upvotes: 2

Related Questions