Thread: Need Help

1. Member
Join Date
Feb 2009
Posts
5
Rep Power
0

Need Help

Hi,
I'm trying to make parsing arithmetic expressions in java for the following:
1. A = (B + C) * D - E;
2. F = (G + H) - (I + J);
3. G = H + A[i];
4. If (I == J) F = G + H;
Else F = G - H;
5. Loop: G = G + A[i];
I = I + J;
If (I != H) Goto Loop;
6. If (G < H) Goto Less;
7. While (save[i] == K)
I = I + J;
If anyone can help me with that
Thank you all.

2. .. You never described exactly what is wrong, and what all those variables are supposed to be.. You pretty much wrote the code yourself there, what do you need?
Java Code:
```double A,B,C,D,E,F,G,H,I,J,K;
/* give the following doubles a value */
B = 0;
C = 0;
D = 0;
E = 0;
G = 0;
H = 0;
I = 0;
J = 0;
double[] save = new double[0]; // do same as next array
double[] Arr = new double[0]; // change the 0 then give the array doubles values
// or do this: double[] Arr = { (double1), (double2), (double3), etc };
/* end */
A = (B + C) * D - E;
F = (G + H) - (I + J);
G = H + Arr[I]; // ? A is not an array... variable changed
if (I == J) {
F = G + H;
}
else {
F = G - H;
}
for(double item:A) {
G += item;
}
I += J;
if(I != H) {
while(save[I] == K)
I += J;
}
}
if(G < H) {
Goto Less; // What is less?
}```
compare to this:
1. A = (B + C) * D - E;
2. F = (G + H) - (I + J);
3. G = H + A[i];
4. If (I == J) F = G + H;
Else F = G - H;
5. Loop: G = G + A[i];
I = I + J;
If (I != H) Goto Loop;
6. If (G < H) Goto Less;
7. While (save[i] == K)
I = I + J;

3. Member
Join Date
Feb 2009
Posts
5
Rep Power
0
Thank you for your replay.
What I need is:
A simulation is to be performed on the assembly code level by
writing a mini-compiler for each ISA:
3, 2-Address Architecture,Accumulator Architecture, Stack Architecture, and Load-Store Architecture.
The purpose of writing a mini-compiler for each ISA,
Thank you
I hope that you got the idea

4. Member
Join Date
Feb 2009
Posts
5
Rep Power
0
Hi
I need both.
I already done the parser
What I need now is the compiler
Thank you

5. Member
Join Date
Feb 2009
Posts
5
Rep Power
0
yes I have.

6. Nael... this is a pretty advanced topic for the "New to Java" sub-forum (I'm not a newbie to Java, but I haven't a clue to what you're looking for. I think you want to make a mini-compiler in Java). If you don't get any responses, maybe you can request the mods that this post be moved to the "Advanced Java" sub-forum.

Luck,
CJSL

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•