Closed Thread
Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 37

Thread: Writing a compiler, need litle guidence

  1. #11
    MiyamotoSamurai is offline Learning Programmer
    Join Date
    Aug 2009
    Posts
    35
    Rep Power
    0

    Re: Writing a compiler, need litle guidence

    If i use python to get the tokens then what i am to do next is build finite state automata model for my language, and just do things like this:

    if (token1 == if && token2 == "(" && token3==ID) do this

    or

    switch(token1){
    case: "if"
    do this
    case:reserved word
    do this
    case:number
    do this

    I mean now i can skip the lex and yacc stuff right? Because python can tokenize for me.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #12
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: Writing a compiler, need litle guidence

    Wait, "if" isn't a valid token in your language.

    I really think you are trying to get into code way too fast. I know you want to do code, but you are likely to make a TON of errors that you will have to go back and rework.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  4. #13
    MiyamotoSamurai is offline Learning Programmer
    Join Date
    Aug 2009
    Posts
    35
    Rep Power
    0

    Re: Writing a compiler, need litle guidence

    You don't understand.

    I am going to use if and switch and string processing in python.

    So the user writes a text file, and my python program translates it into assembler code. And from then the assembler executes. That is my compiler project.

  5. #14
    MiyamotoSamurai is offline Learning Programmer
    Join Date
    Aug 2009
    Posts
    35
    Rep Power
    0

    Re: Writing a compiler, need litle guidence

    oops, double post...

  6. #15
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: Writing a compiler, need litle guidence

    Given that 1) I don't know python, and 2) that I don't know HLA.

    Can you provide an example of what the source might look like and what the "compiled" to HLA code should look like?
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  7. #16
    MiyamotoSamurai is offline Learning Programmer
    Join Date
    Aug 2009
    Posts
    35
    Rep Power
    0

    Re: Writing a compiler, need litle guidence

    well you can check out the syntax on wikipedia or google

    By the way why did you put compile in quotes? Would not that be a compiler? I mean, a c++ compiler for example first compiles to c and then c to assembler and only then to machine code.

  8. #17
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: Writing a compiler, need litle guidence

    Here's my issue: I can't imagine anything meaningful that you could compile "32.4+57.3" into.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  9. #18
    MiyamotoSamurai is offline Learning Programmer
    Join Date
    Aug 2009
    Posts
    35
    Rep Power
    0

    Re: Writing a compiler, need litle guidence

    Oh i see.

    Well I am really on new ground here so, I am starting very slow. So this will be like an excercise for assembler arithmetics operations and translating high level into low.

    Eventually i will get to construct variables, the iterator and recursion constructs, and some data structures.

    But slowly, right now i have two tasks to do:

    1. Try and see what you can do with lex and yacc
    2. Once you get the hang of it, start writing a compiler that will translate a source file in your language into assembler.

    What i have concluded from reading so far, is that i will have to use lex and yacc, otherwise it would be much complicated. So i hope to start sending some code these days. Thank you and cya soon for more

  10. #19
    MiyamotoSamurai is offline Learning Programmer
    Join Date
    Aug 2009
    Posts
    35
    Rep Power
    0

    Re: Writing a compiler, need litle guidence

    So i don't create new threads here i will send my questions related to this project.

    1. The character handler is the section that communicates with the outside world, through the
    operating system, to read in the characters that make up the source text. As character sets and file
    handling vary from system to system, this phase is often machine or operating system dependent.

    What would be the difference here between Linux and Windows for example?

  11. #20
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: Writing a compiler, need litle guidence

    The biggest difference between Windows and Linux is whether a "newline" is #10#13 or just #13.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

Closed Thread
Page 2 of 4 FirstFirst 1234 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Writing an OS
    By Bioshox in forum Java Help
    Replies: 5
    Last Post: 10-13-2011, 05:29 PM
  2. Writing a CV :p
    By wim DC in forum The Lounge
    Replies: 4
    Last Post: 06-22-2011, 02:10 AM
  3. Writing an OS
    By MiyamotoSamurai in forum Computer Software/OS
    Replies: 8
    Last Post: 11-03-2009, 08:45 AM
  4. Replies: 0
    Last Post: 11-20-2008, 01:25 PM
  5. Writing ToS/FAQ?
    By TcM in forum Business and Legal
    Replies: 4
    Last Post: 06-22-2008, 08:56 AM

Tags for this Thread

Bookmarks

Posting Permissions

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