Hi ! ... I think "forest" should be taken literally: What is a forest ? It consists of multiple trees ! Sometimes the trees have distinct roots but may merge...
Kai Schuetz
schuetz.kai@...
Mar 5, 2003 1:17 pm
183
... After I wrote the email, I did some more reading and found out more about how LCC trees and dags work. LCC's frontend builds a list of trees. A tree only...
Hello, This email message is a notification to let you know that a file has been uploaded to the Files area of the compilers101 group. File :...
compilers101@yahoogro...
Mar 7, 2003 9:32 pm
185
Hi, I have added a couple of links that I think will be interesting to the group. One describes in quite good detail the internals and other aspects of the...
... I was just looking at this the other day and decided to implement Small C first. I've put my original C compiler on hold (I have most of the data ...
I can't believe I've got this running again, but it does appear to work! Below is the output from my Skimp compiler for the 6809 which I wrote as a 3rd-yr...
... Where in your compiler is the code for this? I'd like to take a look. ... Well, not quite ;) I have been playing with a small toy parser which accepts C...
... Sorry, it's lamentably commented; we had a manual which explained it all. I have scans of the manual and I may have recently found the source of the...
... look. I have something like a dozen compiler books at home right now and not one of them explains this worth a damn. The best explanation I've found...
I decided to see if I could write the code to convert complex if()s into simple tests and jumps, just to keep my hand in. It's as tricky as I remembered to...
... I persevered. I think it works now. 40: LINE 10: if (((x != i) || (y != j)) && (i == j)) i = j 41: [@AST 5] NE [@AST 13] 42: [@AST 8] NE [@AST 12] 43: OR...
... I'll give it a shot tomorrow afternoon. After that, I'll probably implement switch statements (not looking forward to it) and then the rest of the...
... The principles are easy enough. The key is to avoid being tricked into thinking that ANDs and ORs differ fundamentally from each other. In fact they are...
Rainer Thonnes
rainer@...
Mar 11, 2003 10:57 pm
196
Here's the critical parts of my version of compiling conditionals. It doesn't yet handle negated conditions (eg "if (!(a == b)) ...") or the tweak you need to...
Thanks for posting the code! I think I get the basic idea, I'm going to read your code and Rainer's post a bit more thoroughly to make sure I get it. I'm done...
Below is something I whipped up to day based on the info Rainer and Graham have posted. An input file can only contain one condition with &, (, ), or ...
./cond2 /dev/tty a|b|c|d ... a b c d test a; goto 0 if TRUE test b; goto 3 if FALSE goto 0 3: test c; goto 2 if FALSE goto 0 2: test d; goto 1 if FALSE 0:...
... Hmm, I'll try it again and post the results. ... The 0 and 1 labels are only printed to show that they correspond to true/false. Of course there would be a...
I think the parser below works. If there are any problems, I'd guess they will surface with rightward trees (A&(B|C&(D&E), etc.) I can't say I knew what I was...
It's looking good! To finish it off so its actually usable in your compiler, you need to add actual comparisons (eg ==, !=, < etc) so that you can work out...
... against ... A cmp against 0 can be replaced by a TEST reg,reg on X86 or a TST on 68K. On MIPS and Alpha, I think, there would be no comparison, just a...
... I thought it would be interesting to have a look at some code sequences for conditionals to see the variations possible. They're all pretty similar in...
... I tested this function: int Foo(int a, int b, int c, int d) { if (a && (b || c) && d) return 1; return 0; } On Alpha (w/ GCC -O4): Foo: .frame $30,0,$26,0 ...
... I find Bart's DoCond() function excessively complicated, as it has to look down into the sub-trees of AND- and OR-nodes to decide what to do. ... For what...
Rainer Thonnes
rainer@...
Mar 16, 2003 4:08 pm
207
... Indeed, but to know if that is true you need to actually compile the code in the then/else part rather than guess, because you may have something in there...
... Stochastic programming, eh? If it doesn't work, change something. Change anything. Keep going until it works. Hmm. The logical approach has much to...
Rainer Thonnes
rainer@...
Mar 16, 2003 10:52 pm
209
... Actually, guys, the way I thought about it when I wrote my version was to forget about multiple chains of conditions at the same level and just ask myself...
... Actually, that was the n-ary tree model... The forest model is alive and well ;) Forests are simply trees linked together. In the case of my compiler, they...