Results 1 to 5 of 5
  1. #1
    srivalli is offline Member
    Join Date
    Mar 2014
    Posts
    1
    Rep Power
    0

    Post How to write for a mini compiler

    I need to do a simulation on the assembly code level by writing a mini-compiler for each ISA, i.e., 4, 3, 2-Address Architecture, Accumulator Architecture, Stack Architecture, and Load-Store Architecture.

    The input to the simulator is a segment of C program:
    The basic sample segments of C code are:

    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;

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: How to write for a mini compiler

    Do you have a java programming question?
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,423
    Blog Entries
    7
    Rep Power
    27

    Default Re: How to write for a mini compiler

    Have you written a parser and lexical analyzer (tokenizer) yet? (hint: see one of my blog articles; it implements expression parsing; it can be a fine basis for your little language (the article come with (free!) code)

    kind regards,

    Jos
    Build a wall around Donald Trump; I'll pay for it.

  4. #4
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: How to write for a mini compiler

    Ni! Ni!

    Might be interesting to read through the thread of the previous person who attempted to go into compiler design and by sheer luck found Jos in this here little Java forum:

    http://www.java-forums.org/new-java/...ng-errors.html
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  5. #5
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,423
    Blog Entries
    7
    Rep Power
    27

    Default Re: How to write for a mini compiler

    Quote Originally Posted by gimbal2 View Post
    Ni! Ni!
    *ouch* knock if off, you pig-dog!

    Quote Originally Posted by gimbal2 View Post
    Might be interesting to read through the thread of the previous person who attempted to go into compiler design and by sheer luck found Jos in this here little Java forum:

    http://www.java-forums.org/new-java/...ng-errors.html
    I doubt the OP realizes the complexity of that simple language: the fragments show arrays; they need to be declared; is bounds checking needed? Are 'arrays of arrays' wanted? I see labels; does the OP want to implement back-patching? I also see structures (e.g. the 'while' language structure). What about labels in those structures and jumping to those labels? Is the 'dangling else' problem solved in the grammar? etc. etc. I'm afraid there are more decisions to take than the OP wants to take ...

    kind regards,

    Jos
    Build a wall around Donald Trump; I'll pay for it.

Similar Threads

  1. anyone who can help me fix this opera mini 5.1.22296
    By ejstrider in forum Sun Java Wireless Toolkit
    Replies: 0
    Last Post: 02-05-2011, 05:23 AM
  2. compiler,JIT compiler & interpreter
    By gamilah in forum New To Java
    Replies: 4
    Last Post: 11-04-2008, 12:32 AM

Posting Permissions

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