Results 1 to 8 of 8

Thread: Need Help

  1. #1
    Nael is offline Member
    Join Date
    Feb 2009
    Posts
    5
    Rep Power
    0

    Default 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. #2
    MK12's Avatar
    MK12 is offline Senior Member
    Join Date
    Jan 2009
    Posts
    185
    Rep Power
    6

    Default

    .. 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;
    Tell me if you want a cool Java logo avatar like mine and I'll make you one.

  3. #3
    Nael is offline Member
    Join Date
    Feb 2009
    Posts
    5
    Rep Power
    0

    Default

    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. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

  5. #5
    Nael is offline Member
    Join Date
    Feb 2009
    Posts
    5
    Rep Power
    0

    Default

    Hi
    I need both.
    I already done the parser
    What I need now is the compiler
    Thank you

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

  7. #7
    Nael is offline Member
    Join Date
    Feb 2009
    Posts
    5
    Rep Power
    0

    Default

    yes I have.

  8. #8
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    7

    Default

    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
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

Posting Permissions

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