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.  Reply With Quote

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; // do same as next array
double[] Arr = new double; // 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;  Reply With Quote

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

## What I need is:
A simulation is to be performed on the assembly code level by
writing a mini-compiler for each ISA:
The purpose of writing a mini-compiler for each ISA,
Thank you
I hope that you got the idea  Reply With Quote

4. ## Are you want to write a parser for the logic, or to the compiler you are talking about.  Reply With Quote

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

## Hi
I need both.
What I need now is the compiler
Thank you  Reply With Quote

6. ## To do a compilation you need have to some logics to test in the code, do you?  Reply With Quote

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

## yes I have.  Reply With Quote

8. ## 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  Reply With Quote

#### Posting Permissions

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