[antlr-interest] Don't want to pervert reference grammar like Terence Parr one on Java 1.5

Yang Jiang yang.jiang.z at gmail.com
Wed Nov 12 14:22:07 PST 2008


Another way I can think of is to automatically generate a grammar (from 
the java or sql grammar) which builds a general
data structure, like a tree, then you can do your work on top of that 
and not worrying about the original grammar getting changed.

Then the problems left here is whether or not the metrics you want to 
calculate can be general enough to auto-generate :)
I once wrote such a grammar based on the ANTLRv3 grammar 
(http://www.antlr.org/grammar/ANTLR/ANTLRv3.g) and using rewrite stream,
which converts a java grammar to generate parsing trees. It worked quite 
well.

Cheers,
Yang





Johannes Luber wrote:
> Freddy Mallet schrieb:
>   
>> Hi all,
>>
>> I'd like to create my own Open Source library to calculate metrics on
>> java and pl/sql source code. Those metrics could be lines of code,
>> cyclomatic complexity, maintainability index (SEI), etc. I've studied
>> javacc and antlr, then read the definitive ANTLR Reference.
>>
>> At that point, I guess I've enough material to begin writing this
>> library but ... there is a recurring question I can't evacuate from my
>> brain.
>>
>> Here is my issue : on the shelf, there is already two reference grammars
>> available to parse java and pl/sql. Of course, those two reference
>> grammars will evolve in time to follow java and pl/sql evolutions.
>>
>> Tomorrow, beginning to touch those two grammars to build my own AST or
>> to add my own actions on rules is equivalent to create a new branch on a
>> source code. After few months, the differences between the grammars will
>> be so important that I couldn't synchronize them. So after a while, I
>> couldn't capitalize on ANTLR community work.
>>
>> That's exactly what happens currently to JavaNCSS library. The library
>> used javacc and all work has been done from a Java 1.1 grammar which has
>> now great difficulty to evolve.
>>
>> So, is there an abstraction mechanism which allow us to use on the shelf
>> grammars without modifying them directly ?
>>
>> Thanks for your help,
>>
>> Freddy
>>     
>
> AFAIK, there is a whitepaper on a tool named gdiff, which would be a
> specialized diff for grammars. It would ignore actions and focus only on
> the grammar structure. But I don't know how far the implementation has
> been realized.
>
> Johannes
>
>   
>> -- 
>> Freddy Mallet,
>> Sonar , Embrace Quality
>> http://sonar.codehaus.org
>>
>>
>> ------------------------------------------------------------------------
>>
>>
>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>>
>>     
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>   



More information about the antlr-interest mailing list