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

2005-04-18

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(ClassfileParser.java:490)
[argouml]     at org.argouml.uml.reveng.classfile.ClassfileParser.magic_number(ClassfileParser.java:287)
[argouml]     at org.argouml.uml.reveng.classfile.ClassfileParser.classfile(ClassfileParser.java:258)
[argouml]     at org.argouml.uml.reveng.classfile.ClassfileImport.parseFile(ClassfileImport.java:358)
[argouml]     at org.argouml.uml.reveng.classfile.ClassfileImport.processJarFile(ClassfileImport.java:276)
[argouml]     at org.argouml.uml.reveng.classfile.ClassfileImport.processFile(ClassfileImport.java:228)
[argouml]     at org.argouml.uml.reveng.classfile.ClassfileImport.startImport(ClassfileImport.java:113)
[argouml]     at org.argouml.uml.reveng.classfile.ClassfileImport.parseFile(ClassfileImport.java:95)
[argouml]     at org.argouml.uml.reveng.Import.parseFile(Import.java:431)
[argouml]     at org.argouml.uml.reveng.Import$ImportRun.run(Import.java:582)
[argouml]     at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
[argouml]     at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
[argouml]     at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
[argouml]     at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
[argouml]     at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:141)
[argouml]     at java.awt.Dialog$1.run(Dialog.java:540)
[argouml]     at java.awt.Dialog.show(Dialog.java:561)
[argouml]     at org.argouml.uml.reveng.Import.doFile(Import.java:399)
[argouml]     at org.argouml.uml.reveng.ImportClasspathDialog.doFiles(Import.java:935)
[argouml]     at org.argouml.uml.reveng.ImportClasspathDialog.access$200(Import.java:855)
[argouml]     at org.argouml.uml.reveng.ImportClasspathDialog$OkListener.actionPerformed(Import.java:968)
[argouml]     at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786)
[argouml]     at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839)
[argouml]     at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
[argouml]     at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
[argouml]     at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
[argouml]     at java.awt.Component.processMouseEvent(Component.java:5100)
[argouml]     at java.awt.Component.processEvent(Component.java:4897)
[argouml]     at java.awt.Container.processEvent(Container.java:1569)
[argouml]     at java.awt.Component.dispatchEventImpl(Component.java:3615)
[argouml]     at java.awt.Container.dispatchEventImpl(Container.java:1627)
[argouml]     at java.awt.Component.dispatchEvent(Component.java:3477)
[argouml]     at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
[argouml]     at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)
[argouml]     at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
[argouml]     at java.awt.Container.dispatchEventImpl(Container.java:1613)
[argouml]     at java.awt.Window.dispatchEventImpl(Window.java:1606)
[argouml]     at java.awt.Component.dispatchEvent(Component.java:3477)
[argouml]     at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
[argouml] Exception in org/apache/commons/logging/LogConfigurationException.class : null
[argouml]     at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
[argouml]     at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
[argouml]     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
[argouml]     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
[argouml]     at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)

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(TestCppGrammar.java:116)
at org.argouml.language.cpp.reveng.TestCppGrammar.testParseQuadratic(TestCppGrammar.java:92)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:166)
at junit.framework.TestCase.runBare(TestCase.java:140)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:131)
at junit.framework.TestSuite.runTest(TestSuite.java:173)
at junit.framework.TestSuite.run(TestSuite.java:168)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:231)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:409)
1.23

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!

2005-04-14

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 default.properties and revert the change to antlrall.jar.path to use the 2.7.2 jar. Then argouml/src_new/$ ./build.sh clean package argouml/modules/classfile/$ ant clean install argouml/src_new/$ ./build.sh 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.

2005-04-12

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:

Adam said...

thats great

Reader Shared items

Followers