I'm not sure I know what you mean..... I am not understanding "parse tree" so much, and I'm not quite understanding what you want done with Tabs. If you post code, also, it might be beneficial to use code tags which is bracket [ then the word CODE then ]. If you could just elaborate a little bit on what you need done, I'll see what I can do.
Comatose
Taboo Programmer
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
Ok, what I Meant was that when you post code on the site, use code tags. Open a code tag with [ CODE ] with no spaces. Then close the code tag with [ / CODE ] no spaces. It will look like this, and will preserve tabs on this page for readability:
This is in code Tags
Also, I don't know why you are using the same array that contains all the parts of the split to push and pop from. I would have used a different one, but if it works, cool. I just don't understand HOW it works. Anyway, if you know where the indents need to be, then you can:
foreach $line (@lines) {
@fields = split(/ /, $line);
if ($fields[0] eq 'OPAREN') {
push(@fields, $fields[1]);
print OUTPUT "$fields[0] ";
print OUTPUT "$fields[1]";
}elsif ($fields[0] eq 'CPAREN') {
pop(@fields);
print OUTPUT "$fields[0] ";
print OUTPUT "\t$fields[1]"; # I modified this line, to add a tab first
}elsif (($fields[0] ne 'OPAREN') && ($fields[0] ne 'CPAREN')) {
print OUTPUT "$fields[0] ";
print OUTPUT "$fields[1]";
}
}
Comatose
Taboo Programmer
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215