Ruud
Veteran Member
Hello,
I'm writing my own pascal compiler that should be at least TP4 compatible one day. The why: just for fun. FYI: it doesn't output an executable but a file with macros. With special directives, that just look like comment to TP, my assembler knows for what CPU and what computer it is meant and translates the macros into ML. So far I was able to write little programs for the PC and for the Commodore 64.
Please have a look at this:
i1 := (i2 * (i4 - i3)) * (i4 * (i5 + i6));
The above leads to in between results and I use the Stack to store them
Now let's do the above but for strings:
s1 := (s2 + (s4 + s3)) + (s4 + (s5 + s6));
As far as I can remember I have never seen or written such a line but TP accepts it so I must be able to handle it as well. If I would use the same routine as I used for the first statement, I have to add s4 and s3 first and push the result on the stack. And not knowing how big the results will be, I have to push 256 bytes every time. Not only time consuming but that can also be very costly in needed RAM.
But my own logic says that in case of strings only plus can be used as an operator and in that case I can forget about the parentheses and treat the whole as one big addition.
Can anybody prove me wrong? (I hope not)
Thank you in advance!
I'm writing my own pascal compiler that should be at least TP4 compatible one day. The why: just for fun. FYI: it doesn't output an executable but a file with macros. With special directives, that just look like comment to TP, my assembler knows for what CPU and what computer it is meant and translates the macros into ML. So far I was able to write little programs for the PC and for the Commodore 64.
Please have a look at this:
i1 := (i2 * (i4 - i3)) * (i4 * (i5 + i6));
The above leads to in between results and I use the Stack to store them
Now let's do the above but for strings:
s1 := (s2 + (s4 + s3)) + (s4 + (s5 + s6));
As far as I can remember I have never seen or written such a line but TP accepts it so I must be able to handle it as well. If I would use the same routine as I used for the first statement, I have to add s4 and s3 first and push the result on the stack. And not knowing how big the results will be, I have to push 256 bytes every time. Not only time consuming but that can also be very costly in needed RAM.
But my own logic says that in case of strings only plus can be used as an operator and in that case I can forget about the parentheses and treat the whole as one big addition.
Can anybody prove me wrong? (I hope not)
Thank you in advance!