Re: coco/r of some problem

Detlef Meyer-Eltz <Meyer-Eltz@t-online.de>
16 Apr 2005 11:09:24 -0400

          From comp.compilers

Related articles
coco/r of some problem s9134143@pu.edu.tw (113) (2005-04-11)
Re: coco/r of some problem Meyer-Eltz@t-online.de (Detlef Meyer-Eltz) (2005-04-16)
| List of all articles for this month |

From: Detlef Meyer-Eltz <Meyer-Eltz@t-online.de>
Newsgroups: comp.compilers
Date: 16 Apr 2005 11:09:24 -0400
Organization: Compilers Central
References: 05-04-019
Keywords: tools

"5+6=" can't be recognized, as you forgot to define the "+" token.
Also no values are assigned to tmp and tmp2.
printf("%d",numSym); always will print the same constant value of the
num symbol.


Tip: Look at the CALC.ATG example. It's quite similar to your project.
It demonstrates, how you can assign a value to your variables.




Regards


Detlef Meyer-Eltz


--
mailto:Meyer-Eltz@t-online.de


url: http://www.texttransformer.de
url: http://www.texttransformer.com


--




am Montag, 11. April 2005 um 06:11 schrieben Sie:


> hello,
> i' m testing coco/r


> but my code can't run coco/r.
> give a data .
> ex: tmp.txt


> 5+6=


> i need show answer.
> but i can't do it .


> help~~!!




> /******************************************/


> $c
> COMPILER IC


> CHARACTERS
> digit = "0123456789" .


> TOKENS


> num = digit {digit}.


> PRODUCTIONS


> IC = { Expression "=" }.


> Expression = (. int tmp,tmp2,total;.)
> num
> { "*" num (.total = tmp2 + tmp; printf("%d",numSym);.)
> | "-" num (.total = tmp2 - tmp; printf("%d",numSym);.)} .


> END IC.


> /******************************************/


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.