Thread: compiler

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    39
    Rep Power
    12

    Question compiler


    Hi, anyone here had build a compiler before using C?the compiler that accept high level language and output a C code as target language.
  2. #2
  3. Contributing User

    Join Date
    Aug 2003
    Location
    UK
    Posts
    5,116
    Rep Power
    1803
    Technically that's a translator rather than a compiler. Many early C++ implementations worked this way I believe.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    39
    Rep Power
    12
    Well, it's a type of translator. Can say a compilr too.Just most compiler generate assembly language as output. but my project is to generate C code.Just like VDM tools.anyone can help,please.
  6. #4
  7. Contributing User

    Join Date
    Aug 2003
    Location
    UK
    Posts
    5,116
    Rep Power
    1803
    What high level language do you want to parse? If you are creating a custom or new language, then the UNIX tools lex and yacc may be useful, or the (GNU equivalents flex and Bison). Here are some useful links:

    http://dinosaur.compilertools.net/
    http://www.monmouth.com/~wstreett/le.../lex-yacc.html
    http://www.gnu.org/software/flex/flex.html
    http://www.gnu.org/software/bison/bison.html

    Clifford
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    39
    Rep Power
    12
    Well, i need to parse Z specification.the link u gave is to use lex and yacc?thanx for your help.Can i knwo if any website teach us how to build a compiler?
  10. #6
  11. Contributing User

    Join Date
    Aug 2003
    Location
    UK
    Posts
    5,116
    Rep Power
    1803
    An interesting idea, and possibly a bit too specialist for me or even this forum. I am not familiar with Z, but I have used VDM. Because Z is declarative, and C is procedural, it seems that it is not a conventional compiler/translator that you are suggesting (I may be wrong on this). Prolog would be the natural language for 'animating' Z program specifications since that is an executable declarative language. There is a paper on this subject:
    www1.dogus.edu.tr/dogustru/journal/sayi_1/m00012.pdf

    Clifford
    Last edited by clifford; September 16th, 2003 at 12:16 PM.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    39
    Rep Power
    12
    well, I'm just looking for some clues for starting my project.Cos I dunno how to start it. If anyone got example in building translator that generate a C code as output, mind to tell me?I just wan to use it as reference. A tutorial will be deeply appreciate. As far as I know build a compiler is time consuming but I dont have much time. I hope someone can help.Thanx Clifford.

IMN logo majestic logo threadwatch logo seochat tools logo