[antlr-interest] Re: C# vs MSIL Output

Ney, Richard richard.ney at aspect.com
Mon Mar 8 16:40:28 PST 2004


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. 

I'm not sure if this is the type of operation you are looking at but if
your application needs performance I really recommend that you make the
extra jump and have your ANTLR code generate MSIL for the
transformation. 

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 opens
the door to rouge code insertion since there is a small lag between the
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
possible. 

-Richard

-----Original Message-----
From: micheal_jor [mailto:open.zone at virgin.net] 
Sent: Monday, March 08, 2004 3:33 AM
To: antlr-interest at yahoogroups.com
Subject: [antlr-interest] Re: C# vs MSIL Output

--- In antlr-interest at yahoogroups.com, "Mike Bresnahan"
<mbresnah at v...> wrote:
> I'm beginning a project to create a .NET mini-language for
performing data
> transformations.  I'm currently debating which of following would be
best:
> 
> A) compile the language into a data structure that is used by a
runtime
> engine to perform the transformations
> B) compile the language into C# code that performs the transformations
> (after a second compilation)
> C) compile the language directly to MSIL (.NET virtual machine
assembly-like
> language) that performs the transformations
> 
> Here's a breakdown of how I see these approaches comparing based on 3
> criteria: ease of implementation, execution speed, and compilation
speed
> 
> Option    Implementation  execution  compilation
> -------------------------------------------------
> A         easy            slow       fast
> B         medium          fast       slow
> C         hard            fast       medium
> 
> I'm currently leaning towards C, because a) it appears to have the
best
> trade off between execution and compilation speed b) it is the
approach
> taken by XSLTC (albeit in Java) and NMock, and c) it sounds like fun.
> However, I am aware that ANTLR choose option B for its C#/.NET code
> generator.  Would the designers of that piece care to share some
insight
> with me?

One of ANTLR's main selling point is that it generates code fit for
humans to read, understand and even edit (editing the source grammar
is almost always preferable however). Hence the choice of B for
ANTLR/C# was a no-brainer.

Going back to your options, are you aware of these toolkits?
 - Runtime Assembly Instrumentation Library
   http://rail.dei.uc.pt/
 - Abstract IL
   http://research.microsoft.com/projects/ilx/

Of the two, Abstract IL seems the more relevant for your requirements
as it seems to help in implementing option C.

Cheers,

Micheal
ANTLR/C#




 
Yahoo! Groups Links



 



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
     antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/
 



More information about the antlr-interest mailing list