As an ArgoUML contributor I'm going to blog my activities here, so that they may draw interest by other developers or help other developers when doing tasks similar to what I've done. AND(!) the grand vision that makes an Argonaut what he is, TO THRIVE IN THE BIG DANGEROUS WORLD, TAKING THE Argo TO A GOOD SHORE ;-))

Tuesday, April 19, 2005

fixing the grammar II


I'm going to give a try with ANTLR 2.7.5 again. Maybe the error wasn't related to 2.7.5 and due to the state ArgoUML was when I attempted revenging of commons logging. When testing with 2.7.2 it was in the initial state...

Nope, it is there... Here is a piece of the stack trace:

  [argouml] Exception in org/apache/commons/logging/Log.class : null
[argouml] java.lang.NullPointerException
[argouml]     at org.argouml.uml.reveng.classfile.ClassfileParser.u4(
[argouml]     at org.argouml.uml.reveng.classfile.ClassfileParser.magic_number(
[argouml]     at org.argouml.uml.reveng.classfile.ClassfileParser.classfile(
[argouml]     at org.argouml.uml.reveng.classfile.ClassfileImport.parseFile(
[argouml]     at org.argouml.uml.reveng.classfile.ClassfileImport.processJarFile(
[argouml]     at org.argouml.uml.reveng.classfile.ClassfileImport.processFile(
[argouml]     at org.argouml.uml.reveng.classfile.ClassfileImport.startImport(
[argouml]     at org.argouml.uml.reveng.classfile.ClassfileImport.parseFile(
[argouml]     at org.argouml.uml.reveng.Import.parseFile(
[argouml]     at org.argouml.uml.reveng.Import$
[argouml]     at java.awt.event.InvocationEvent.dispatch(
[argouml]     at java.awt.EventQueue.dispatchEvent(
[argouml]     at java.awt.EventDispatchThread.pumpOneEventForHierarchy(
[argouml]     at java.awt.EventDispatchThread.pumpEventsForHierarchy(
[argouml]     at java.awt.EventDispatchThread.pumpEventsForHierarchy(
[argouml]     at java.awt.Dialog$
[argouml]     at
[argouml]     at org.argouml.uml.reveng.Import.doFile(
[argouml]     at org.argouml.uml.reveng.ImportClasspathDialog.doFiles(
[argouml]     at org.argouml.uml.reveng.ImportClasspathDialog.access$200(
[argouml]     at org.argouml.uml.reveng.ImportClasspathDialog$OkListener.actionPerformed(
[argouml]     at javax.swing.AbstractButton.fireActionPerformed(
[argouml]     at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(
[argouml]     at javax.swing.DefaultButtonModel.fireActionPerformed(
[argouml]     at javax.swing.DefaultButtonModel.setPressed(
[argouml]     at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(
[argouml]     at java.awt.Component.processMouseEvent(
[argouml]     at java.awt.Component.processEvent(
[argouml]     at java.awt.Container.processEvent(
[argouml]     at java.awt.Component.dispatchEventImpl(
[argouml]     at java.awt.Container.dispatchEventImpl(
[argouml]     at java.awt.Component.dispatchEvent(
[argouml]     at java.awt.LightweightDispatcher.retargetMouseEvent(
[argouml]     at java.awt.LightweightDispatcher.processMouseEvent(
[argouml]     at java.awt.LightweightDispatcher.dispatchEvent(
[argouml]     at java.awt.Container.dispatchEventImpl(
[argouml]     at java.awt.Window.dispatchEventImpl(
[argouml]     at java.awt.Component.dispatchEvent(
[argouml]     at java.awt.EventQueue.dispatchEvent(
[argouml] Exception in org/apache/commons/logging/LogConfigurationException.class : null
[argouml]     at java.awt.EventDispatchThread.pumpOneEventForHierarchy(
[argouml]     at java.awt.EventDispatchThread.pumpEventsForHierarchy(
[argouml]     at java.awt.EventDispatchThread.pumpEvents(
[argouml]     at java.awt.EventDispatchThread.pumpEvents(
[argouml]     at

So, to fix the C++ grammar, the first thing to do is to show what the error is:

testParseQuadratic Error unexpected token: (

line 5960:25: unexpected token: (
at org.argouml.language.cpp.reveng.CPPParser.unary_expression(Unknown Source)
at org.argouml.language.cpp.reveng.CPPParser.cast_expression(Unknown Source)
at org.argouml.language.cpp.reveng.CPPParser.pm_expression(Unknown Source)
at org.argouml.language.cpp.reveng.CPPParser.multiplicative_expression(Unknown Source)
at org.argouml.language.cpp.reveng.CPPParser.additive_expression(Unknown Source)
at org.argouml.language.cpp.reveng.CPPParser.shift_expression(Unknown Source)
at org.argouml.language.cpp.reveng.CPPParser.relational_expression(Unknown Source)
at org.argouml.language.cpp.reveng.CPPParser.equality_expression(Unknown Source)
at org.argouml.language.cpp.reveng.CPPParser.and_expression(Unknown Source)
at org.argouml.language.cpp.reveng.CPPParser.exclusive_or_expression(Unknown Source)
at org.argouml.language.cpp.reveng.CPPParser.inclusive_or_expression(Unknown Source)
at org.argouml.language.cpp.reveng.CPPParser.logical_and_expression(Unknown Source)
at org.argouml.language.cpp.reveng.CPPParser.logical_or_expression(Unknown Source)
at org.argouml.language.cpp.reveng.CPPParser.conditional_expression(Unknown Source)
at org.argouml.language.cpp.reveng.CPPParser.assignment_expression(Unknown Source)
at org.argouml.language.cpp.reveng.CPPParser.expression(Unknown Source)
at org.argouml.language.cpp.reveng.CPPParser.jump_statement(Unknown Source)
at org.argouml.language.cpp.reveng.CPPParser.statement(Unknown Source)
at org.argouml.language.cpp.reveng.CPPParser.statement_list(Unknown Source)
at org.argouml.language.cpp.reveng.CPPParser.compound_statement(Unknown Source)
at org.argouml.language.cpp.reveng.CPPParser.function_definition(Unknown Source)
at org.argouml.language.cpp.reveng.CPPParser.member_declaration(Unknown Source)
at org.argouml.language.cpp.reveng.CPPParser.class_specifier(Unknown Source)
at org.argouml.language.cpp.reveng.CPPParser.type_specifier(Unknown Source)
at org.argouml.language.cpp.reveng.CPPParser.declaration_specifiers(Unknown Source)
at org.argouml.language.cpp.reveng.CPPParser.declaration(Unknown Source)
at org.argouml.language.cpp.reveng.CPPParser.external_declaration(Unknown Source)
at org.argouml.language.cpp.reveng.CPPParser.decl_namespace(Unknown Source)
at org.argouml.language.cpp.reveng.CPPParser.external_declaration(Unknown Source)
at org.argouml.language.cpp.reveng.CPPParser.translation_unit(Unknown Source)
at org.argouml.language.cpp.reveng.TestCppGrammar.parseFile(
at org.argouml.language.cpp.reveng.TestCppGrammar.testParseQuadratic(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at junit.framework.TestCase.runTest(
at junit.framework.TestCase.runBare(
at junit.framework.TestResult$1.protect(
at junit.framework.TestResult.runProtected(
at junit.framework.TestSuite.runTest(

The parser complains about the line 5960, column 25 of quadratic.i. Which is (marked in red):

                {return ((char)_Narrow((_E)(_C))); }

Well, this is perfectly legal C++. So, lets try to fix it!


Log4j configurations should have date

I previously solved this problem. The original text might be used to create an issue. I'll have to make a diff to apply the patch.

Fixing the C++ grammar

Upgrading to ANTLR 2.7.5 didn't fixed the problem as I expected. It also doesn't seam to have broken anything, even for the java and classfile modules. I must now make some manual tests to make sure.

The java reveng works fine with ANTLR 2.7.5, but, the classfile reveng failed when parsing the commons logging jar. I must check if the same happens with ANTLR 2.7.2... So, I must get back to the and revert the change to antlrall.jar.path to use the 2.7.2 jar. Then argouml/src_new/$ ./ clean package argouml/modules/classfile/$ ant clean install argouml/src_new/$ ./ run and test reverse engineering again commons-logging.jar.

And it works! So, something is going wrong when the ANTLR 2.7.5 is used... Since it didn't fixed the problem with C++ parser, I'll stick with version 2.7.2 and maybe create an issue for upgrading with the information that it breaks the classfile reveng.


After discovering that I had to make some work on the grammar to enable reveng, I been off of development for some time. Now its time to get back and grab this issue!

Fixing the C++ grammar

I think that before starting to change the grammar by adding callbacks to the grammar, to support reverse engineering as the original C++ and java grammars do, I must fix the grammar. Mainly because I think the problems it has to parse the quadratic.i file are related to ArgoUML using an old version of ANTLR. So, to try to fix this I must use the current version of ANTLR to generate the parsers. I may try to replace the global ANTLR instead of adding the newer version to the C++ module.

[It would be nice, though, to try to check if ArgoUML module runtime model handles several versions of the same libraries. But, I think I should not open this new front of work!...]

1 comment:

Anonymous said...

thats great

Reader Shared items