# Need Help

• 02-09-2009, 12:14 AM
Nael
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.
• 02-09-2009, 12:40 AM
MK12
.. 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?
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:
Quote:

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;

• 02-09-2009, 12:56 AM
Nael
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
• 02-09-2009, 03:47 AM
Eranga
Are you want to write a parser for the logic, or to the compiler you are talking about.
• 02-09-2009, 08:46 AM
Nael
Hi
I need both.
What I need now is the compiler
Thank you
• 02-10-2009, 05:34 AM
Eranga
To do a compilation you need have to some logics to test in the code, do you?
• 02-10-2009, 11:20 PM
Nael
yes I have.
• 02-11-2009, 01:08 AM
CJSLMAN
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