From: Jendrik J. <jen...@tu...> - 2007-11-23 09:26:09
|
Hi Andreas, please apologize for the late reply. At first, the "*dummy();" thing works, because according to the grammar "*dummy();" is already a complete program and resueware parses only this part. If it finds one complete programs it attempts to parse the remaining part as well, but gives no error if it fails (this might actually be a bug). This means the example can not be parsed regardlessly if you put "*dummy{};" in front of it or not. Consequently there must be mistakes in the grammar. The grammar is quiet big, so it is hard for me to get an overview. One problem seems to be the return type of a method: * main( int argc, char *args[] ) { } is parsed, while int main( int argc, char *args[] ) { } is not. Another problem is there with array declarations: int array; is okay, but int array[100]; gives errors. The reuseware tooling is not very advanced for grammar debugging. If you can not find the mistakes, one thing you could do is looking at the generated ANTLR file "c.g" in "de.tudresden.reuseware.language.c.textsyntax.c" and analyze it with some ANTLR tool. I think they have a good graphical tool now, but I have not tried it myself (www.antlr.org). Hope that helps, Jendrik Andreas Leha wrote: > Hi there, > > I am trying to get reuseware to understand (at least partial) C code. > Unfortunatly I experience strange behaviour: reuseware accepts this: > *dummy{}; > > int main( int argc, char *args[] ) { > int index; > int array[100]; > > for(index = 0; index < 100; index++) { > array[index] = 0; > } > > return 0; > } > But without the leading dummy line, the code raises errors. Strange is, > that just regenerating language plugins and text parsers leads to > different errors here. Anyway, all the errors are similar to this: > state 0 (decision=75) no viable alt; token=[@5,10:12='int',<97>,1:10] > or > mismatched token: [@5,10:12='int',<97>,1:10]; expecting ')' > And they indicate, that function definitions or array declarations... > are not recognized. > > So my question is: Why does reuseware accept C code just after the > leading line "*dummy{};"? > > I've attached the grammars (that follow closely the K&R, 2nd edition). > > > Regards, > > Andreas Leha > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > > > ------------------------------------------------------------------------ > > _______________________________________________ > Reuseware-users mailing list > Reu...@li... > https://lists.sourceforge.net/lists/listinfo/reuseware-users -- Dipl.-Medieninf. Jendrik Johannes Research Assistant Technische Universität Dresden Department of Computer Science Phone +49 351 463 42073 Fax +49 351 463 38459 Email jen...@tu... |