[antlr-interest] Re: C# vs MSIL Output
richard.ney at aspect.com
Mon Mar 8 20:30:19 PST 2004
I've included a sample tree grammar that generates the body of my simple
expression evaluators. The classes you are looking for are in the
System.Reflection.Emit namespace. They allow you to generate classes in
memory using MSIL. Now one thing I will point out is that when you
generate in memory MSIL you still get all the abilities of .NET so you
can include a broiler plate superclass that has common methods that can
use in you MSIL. If you are looking at MSIL I assume you have discovered
ILDASM.exe which will allow you to view code you have written in C# as
MSIL. Also there is an option you can set during debugging on the Emit
object that will save the class to a file so you can examine it with
MSIL. I hope this helps get you started.
From: Mike Bresnahan [mailto:mbresnah at visi.com]
Sent: Monday, March 08, 2004 5:55 PM
To: antlr-interest at yahoogroups.com
Subject: RE: [antlr-interest] Re: C# vs MSIL Output
> I have an application that converts data fetched from a database with
> one schema into the data model for a logical schema. I use the ANTLR
> with C# and I have an SQL Parser that generates a bunch of ASTs that
> represent each column in the logical query and which physical columns
> are used to make render it. The tree parser is excellent for doing
> ILGenerator.Emit calls to create MSIL in memory to make the
> transformation and the performance is very good.
Does your emitted IL perform selections, cartesian products,
unions, intersections, etc?
Is your source code freely available?
> Also from a security point of view dropping C# files onto the disk and
> compiling so you can load them into your application domain. This
> the door to rouge code insertion since there is a small lag between
> time you generate the file, compile it and load it. I admit this is a
> small window and if random file names are used hard to do but it is
Good point. The option
System.CodeDom.Compiler.CompilerParameters.GenerateInMemory states that
resultant assembly is generated in memory, not on disk. However I do
know if the compiler uses intermediate temporary files.
Yahoo! Groups Links
Yahoo! Groups Links
<*> To visit your group on the web, go to:
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 24096 bytes
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20040308/9efb9279/ExpressionTreeParser.obj
More information about the antlr-interest