Results 1 to 8 of 8
Thread: Need Help
- 02-08-2009, 11:14 PM #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.
- 02-08-2009, 11:40 PM #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?
compare to this: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? }
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;
Tell me if you want a cool Java logo avatar like mine and I'll make you one.
- 02-08-2009, 11:56 PM #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
- 02-09-2009, 02:47 AM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Are you want to write a parser for the logic, or to the compiler you are talking about.
- 02-09-2009, 07:46 AM #5
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
- 02-10-2009, 04:34 AM #6
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
To do a compilation you need have to some logics to test in the code, do you?
- 02-10-2009, 10:20 PM #7
Member
- Join Date
- Feb 2009
- Posts
- 5
- Rep Power
- 0
yes I have.
- 02-11-2009, 12:08 AM #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,
CJSLChris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks