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

    Join Date
    Jul 2009
    Posts
    2
    Rep Power
    0

    Question My own programming language


    I have a question. I think I can make my own programming language in C#, though how can I compile that language, into something like html, javascript, or any other language? Can that be done with Microsoft Visual C#? If it cannot, then what can I use for that. I also have experience with C/C++.

    Thanks in advance!
  2. #2
  3. Lord of the Dance
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2003
    Posts
    3,534
    Rep Power
    1906
    Can i ask why you want to create your own programming language, instead of using one that already exists?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2009
    Posts
    2
    Rep Power
    0
    Originally Posted by MrFujin
    Can i ask why you want to create your own programming language, instead of using one that already exists?
    Well, basically I would really like to learn how to make one, I really have a lot of time in my hands. Plus I think that it might be quite useful for specific aplications that may not need certain things.
  6. #4
  7. Lord of the Dance
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2003
    Posts
    3,534
    Rep Power
    1906
    there already exists one thread called Create my own programming language.

    Maybe you could start reading the information that have been posted there.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2004
    Location
    San Francisco Bay
    Posts
    1,939
    Rep Power
    1313
    Originally Posted by freetrader0000
    I have a question. I think I can make my own programming language in C#, though how can I compile that language, into something like html, javascript, or any other language? Can that be done with Microsoft Visual C#? If it cannot, then what can I use for that. I also have experience with C/C++.

    Thanks in advance!
    I have no idea what you're asking. You want to compile your programming language into HTML? What does that even mean?
  10. #6
  11. PixHost.tk Developer
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2009
    Location
    Brazil
    Posts
    58
    Rep Power
    0
    I was trying to do this thing as a time, then i go to develop an OS written in Assembly, it's good.
  12. #7
  13. Commie Mutant Traitor
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2004
    Location
    Norcross, GA (again)
    Posts
    1,804
    Rep Power
    1569
    Compiler design is a fairly large project in and of itself; I would recommend learning about compilers with some subset of an existing language before going ahead with trying anything novel. This is a fairly standard project for an undergrad CS course on compilers (with the grad class being more of the same in more depth); there are several textbooks on the topic, with the Compilers: Principles, Techniques, and Tools being the one used by most courses. In the US at least, most public and university libraries have at least book on the subject.

    There are also several online tutorials and pages on the subject floating around, of varying quality. Fortunately, there are several ways of doing this, so even an bad tutorial can be insightful.


    You may also want to see the Compiler and Language Wiki, though that seems to be very much a work in progress.

    To get you started:
    compiling generally has three main stages, Lexical analysis (breaking the source code into a stream of tokens), parsing (processing the token stream for it's grammatical structure), and code generation (the resulting output, whether as an executable file or a source file for a different language). Most compilers use some sort of intermediate stage between the parser and the code generator (to separate the parts specific to the language from the parts specific to the target system, making it easier to re-target the compiler to a different system), and many have some sort of optimizer either between the parser and the code generator, or after the code generator, or both.

    To do this right, you should learn something about context-free grammars (and Backus-Naur Form in particular) and Deterministic Finite State Automata, and have a good grasp of the target language (usually some form of assembly language, but in principle it could be any Turing Complete language - rules out markup languages such as HTML).

    Adding OS design on top of that... that way madness lies. I of all people know that. Hasn't stopped me from working on and off on it for 15 years, and I doubt it will stop you, either, but I thought I'd at least warn you about the open-ended time sink such a project can become.

    This thread describes part of a compiler I wrote for a course I took last year, including an attachment with the compiler source code (in Python) for you to look at, if you'd like. HTH.

    EDIT: Fixed the links and markup. sigh This is what I get for rushing to post this before leaving.

    Comments on this post

    • medialint agrees
    • nathanpc agrees : Very good and very explained post!
    Attached Files
    Last edited by Schol-R-LEA; August 27th, 2009 at 11:57 AM. Reason: Fixed broken links and markup
    Rev First Speaker Schol-R-LEA;2 JAM LCF ELF KoR KCO BiWM TGIF
    #define KINSEY (rand() % 7) λ Scheme is the Red Pill
    Scheme in Short Understanding the C/C++ Preprocessor
    Taming Python A Highly Opinionated Review of Programming Languages for the Novice, v1.1

    FOR SALE: One ShapeSystem 2300 CMD, extensively modified for human use. Includes s/w for anthro, transgender, sex-appeal enhance, & Gillian Anderson and Jason D. Poit clone forms. Some wear. $4500 obo. tverres@et.ins.gov
  14. #8
  15. PixHost.tk Developer
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2009
    Location
    Brazil
    Posts
    58
    Rep Power
    0
    Schol-R-LEA, you can correct your tags, please!
  16. #9
  17. Commie Mutant Traitor
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2004
    Location
    Norcross, GA (again)
    Posts
    1,804
    Rep Power
    1569
    Sorry 'bout that, Nathanpc. I've fixed that bad markup, and added some more information and links that I hadn't had time to include the first time through.
    Rev First Speaker Schol-R-LEA;2 JAM LCF ELF KoR KCO BiWM TGIF
    #define KINSEY (rand() % 7) λ Scheme is the Red Pill
    Scheme in Short Understanding the C/C++ Preprocessor
    Taming Python A Highly Opinionated Review of Programming Languages for the Novice, v1.1

    FOR SALE: One ShapeSystem 2300 CMD, extensively modified for human use. Includes s/w for anthro, transgender, sex-appeal enhance, & Gillian Anderson and Jason D. Poit clone forms. Some wear. $4500 obo. tverres@et.ins.gov
  18. #10
  19. PixHost.tk Developer
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2009
    Location
    Brazil
    Posts
    58
    Rep Power
    0
    Thanks my friend!

IMN logo majestic logo threadwatch logo seochat tools logo