[antlr-interest] real-life programs

Jim Idle jimi at temporal-wave.com
Thu Feb 7 06:53:01 PST 2008


Peter,

 

 

In answer to 1) I have a commercial version of a C# parser built to
ECMA-334 4th edition that will soon be available. This does all the
pre-processing (in the lexer as per the spec), supports generics and
everything else as per the spec – there are no omissions. I am currently
completing the tree grammar and then it will be ready for release with
the Java target, after which C and C# targets will follow. I am not
suggesting that you would have to buy this from me, just pointing out
that building commercial grade parsers is eminently possible right now.
I also have parsers for other languages working in released products at
various companies (mostly the C target). There are sometimes a few
issues to deal with, but no show stopping problems.

 

In answer to 2, I have obviously done so with the C# parser and also
with query languages and so on. There is nothing stopping you but your
own time and ingenuity ;-)

 

In answer to 3, ANTLR does support scopes in the grammar, and they can
be useful for symbol tables or level tracking variables and so on.
However, I am not sure exactly what your requirement is of course J. For
C#, you really need to build a symbol handler and handle symbols and
semantics in multiple passes. Scopes can make it easier to see which
level you are at and therefore which symbol table and so on, but there
are other approaches of course.

 

Jim

 

From: Peter Bulychev [mailto:peter.bulychev at gmail.com] 
Sent: Thursday, February 07, 2008 2:39 AM
To: antlr-interest at antlr.org
Subject: [antlr-interest] real-life programs

 

Hello.

Thank for answering my previous question. I want to reformulate it more
generally now. Of course, I can get the answers on some points by
myself, but if you answer me, it will  save my time great and maybe it
will be useful to somebody else in future.

1. Is ANTRL suitable to parse real-life programs? For instance, is it
   possible to write a grammar, using which I will be able to parse all
   C# projects from SourceForge? I agree with fact of missing some
   details such as preprocessing directives but I want all files to be
   parsed. Maybe, the grammar should be less strict than the programming
   language.
2. Can I modify this grammar to generate AST representations of
   real-life programs? 
3. Is it possible to work with scopes of variables? I want to "glue
   together" all leaves with the same variable.


Thank you.

-- 
Best regards,
   Peter Bulychev. 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080207/98ac0ca7/attachment.html 


More information about the antlr-interest mailing list