PDA

View Full Version : coco/r for delphi



noeska
17-01-2010, 06:10 PM
Is there an up to date coco/r parser for delphi?
Currently i am using parserbuilder but that one is out of date (2002) and does not support IF (allowing my to check if character form a type i parsed earlier) Also the tetzel version does not support that one.
The current c# version should be capeable.
Now the most up to date version of coco/r for delphi should be http://cc.codegear.com/Item/26667 but that one apears to be very broken when compile with delphi2009, but should have support for IF
Also compiling the tetzel version from source with delphi2009 makes the compiled exe go haywire with only generation rubish in files.
So once again delphi2009 is not playing nice.
Who can help?

Thanks for your help in advance.

Ñuño Martínez
19-01-2010, 09:40 AM
Hi.

I was testing COCO/R some months ago. Finally I did compiled the Turbo Pascal version because none of the most modern ones did work. BTW I use Free Pascal ::) . Finally I decided not to use it because it was too complex and I hadn't find much documentation, and the one I find is for the GUI version (Delphi only).

Anyway it seems that Pascal version is very out of date. If you can build it please let me us know. :)

noeska
19-01-2010, 05:19 PM
Did you find an alternative?

Also the tetzel and parserbuilder should be fairly equal to the pascal only version, but then again in term of coco/r they are old too. The one on codegear is supposed to be the only version up to date only i cannot get it to work with delphi2009.

Coco/r has a steap learning curve. But once thing fall together you say wow. But for now i need the IF so i can determine if a word has been given a maining as type or const definition so i can decide in what way to parse a line. Without IF things become very complex, if not undoeable.

Alternatives would be lex yacc or goldparser.

VilleK
19-01-2010, 08:45 PM
Coco/R is great and I couldn't write a compiler without it :)

I use the Tetzel precompiled version to generate a parser that I use with Delphi 2010. But I haven't yet needed the IF-statement. I remember being surprised to find Tetzel did not support it because I thought I read about it in the documentation.

So is it because of Unicode that the D2009-version does not work? Have you tried compiling it with an earlier version of Delphi? Or contacted the author?

Ñuño Martínez
20-01-2010, 06:40 AM
Did you find an alternative? No, I didn't. I'm writting a compiler by hand. Recursive parsing, you know. ;)

noeska
20-01-2010, 05:18 PM
So is it because of Unicode that the D2009-version does not work? Have you tried compiling it with an earlier version of Delphi? Or contacted the author?

Probeably. The version on codegear compiles ok, but when generating sources with it the resulting files are garbled up with only some parts readeable, but when opening in delphi2009 all i see is numbers. I made a comment on the codegear download as i could not find an email for the author there.

The tetzel also does not compile with delphi 2009 as it gives errors on compiling due to string vs ansistring. Replacing string with ansistring and char with ansichar blindly gives an version that compiles, but just like the version on codegear that gives garbled output files.

Unfortunately the only delphi that i can use is delphi2009. Maybe i should dig up the delphi7 installer and make a virtual pc for it.

How do you handle typecasting then? var2 := typecast(variable); vs var2 := function(variable);

VilleK
23-01-2010, 03:39 PM
I downloaded the Codegear-version to see if I could fix it but the output mechanism seems to complicated for an easy adjust to unicode Delphi. However, there is an email-adress to the author in the file notice.txt if you want to contact him directly.

My small scripting language doesn't have explicit typecasts so I haven't needed to solve that parsing problem.

VilleK
10-10-2011, 02:00 PM
The version on codegear compiles ok, but when generating sources with it the resulting files are garbled up with only some parts readeable, but when opening in delphi2009 all i see is numbers. I made a comment on the codegear download as i could not find an email for the author there.
I had to update my Coco/R generated parser and found out just like you that this version generates garbled output files. I tried to contact the author on several different email-addresses but got no reply. Finally I found the problem in the source code and uploaded it here: http://code.google.com/p/dcocor/

Now it generates correct output when compiled in Unicode-versions of Delphi.

paul_nicholls
11-10-2011, 01:53 AM
I had to update my Coco/R generated parser and found out just like you that this version generates garbled output files. I tried to contact the author on several different email-addresses but got no reply. Finally I found the problem in the source code and uploaded it here: http://code.google.com/p/dcocor/

Now it generates correct output when compiled in Unicode-versions of Delphi.

Nice work VilleK, I might check it out (pun intended!) :D

cheers,
Paul

Ñuño Martínez
18-10-2011, 07:10 PM
I can't see how to download it. Should I use SVN? Will it compile on FPC?

BTW, thanks for the work. :)

paul_nicholls
18-10-2011, 08:46 PM
I can't see how to download it. Should I use SVN? Will it compile on FPC?

BTW, thanks for the work. :)

There is no separate download, go here:
http://code.google.com/p/dcocor/source/checkout

and use SVN :)

cheers,
Paul

VilleK
19-10-2011, 01:47 PM
Yep, use a Subversion client to download the code! Not sure if it will work on Fpc, haven't tried that myself.

Ñuño Martínez
19-10-2011, 06:51 PM
I downloaded it, but I can't compile it. It uses the Windows unit and I use Linux. I tried to fix it but it also uses assembler and FPC doesn't identifies it correctly (IIRC FPC uses "GNU style" not "Intel style"). :(

BTW, can anybody publish a yet compiled executable? I'll test it using WineHQ (http://www.winehq.org/about/). May be it works.