Thread: writing an interpreted language

  1. #1
    Registered User Aran's Avatar
    Join Date
    Aug 2001
    Posts
    1,301

    writing an interpreted language

    I've been thinking of ideas for a new project, and one of the ones that i'm liking alot now is making an interpreted programming language that's compiled into C++, then compiled with a C++ compiler into an exe.

    How difficult would this be to do?

    Will the langauge that i create have any potential for use?

    i'm also looking for someone with a few years of experience with varying programming languages to give me some syntax ideas and general advice.

    any help is greatly appreciated.

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    305
    your language may take some speed hits unless you can work constantly to avoid the traps... as for how easy it would be to code, i think itd be too simple for someone like you that has almost 1000 posts here . this is more like a "translated language". is that a new term?

  3. #3
    well the way you plan on doing it, wouldn't be too hard. Basically be good with I/O and converting stuff to C++. Then you're set.

    Now if you are making one that gets interpreted at run-time, that would be tricky.

  4. #4
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Sounds pretty interesting. All you have to do ( well, in general ) is to interpret the input into C/C++ syntax, then feed the result directly into a command-line compiler. If you're good at parsing, the rest should be fairly straight-forward...
    Let me know how it goes.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  5. #5
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    >>i think itd be too simple for someone like you that has almost 1000 posts here

    How do you know that 90% of his posts are not just things like:
    Hrrmmm....
    or:
    C'mon...20 hits and not posts??
    or:
    How do I clear the screen?
    Postcounts dont necessarily portray a person's ability to code, for eg. if some pro came to this board and had just signed up and had few posts, would you say that he was a newb just becuase of this fact?

  6. #6
    Registered User
    Join Date
    Sep 2001
    Posts
    305
    Originally posted by face_master
    >>i think itd be too simple for someone like you that has almost 1000 posts here

    How do you know that 90% of his posts are not just things like:
    orr:Postcounts dont necessarily portray a person's ability to code, for eg. if some pro came to this board and had just signed up and had few posts, would you say that he was a newb just becuase of this fact?
    great speech ...

  7. #7
    Registered User billholm's Avatar
    Join Date
    Apr 2002
    Posts
    225

    Lightbulb

    >Postcounts dont necessarily portray a person's ability to code, for eg. if some pro came to this board and had just signed up and had few posts, would you say that he was a newb just becuase of this fact?


    Yah I agree!
    All men are created equal. But some are more equal than others.

    Visit me at http://www.angelfire.com/my/billholm

  8. #8
    Registered User
    Join Date
    Feb 2002
    Posts
    114
    Potential use for an iterpreted language might be as a scripting language for games.

    U can do it the easy way by cheating and just use C defines for the language:

    A Basic style "define-language":
    Code:
    #define If if(
    #define Then ){
    #define EndIf }
    #define Else }else{
    #define Print(a) cout << a;
    
    If true == false Then
        Print("True")
    Else
        Print("False")
    EndIf
    put all the defines in a headerfile and include that file in all your "script-files"... compile with your standard compiler...

    If you want code that compile and execute runtime... then thats another question...

  9. #9
    Registered User
    Join Date
    Sep 2001
    Posts
    305
    a scripting language for a game wouldnt have to be translated to C++. it would be more like executing the code at runtime.

  10. #10
    Registered User
    Join Date
    Sep 2001
    Posts
    305
    face_master, billholm: it also looks to me like Aran here is a mod.

  11. #11
    Registered User
    Join Date
    Jun 2002
    Posts
    13
    This looks interesting. What you could do is make a lexicon, and by using switch/case statements you could execute instructions based on the data read from a file. I'm a newbie to C++ but in C it would be like
    Code:
        FILE *fp;
        char str[80];
    
        fgets(&str, 80, fp);
    
        switch(str) 
          ...

  12. #12
    Registered User Aran's Avatar
    Join Date
    Aug 2001
    Posts
    1,301
    i'm not a mod. and i'm actually a respected member here for my role in the GD board. I'm one of the people who first got ........ed of at one-line posts.

    I also know my way around C++ to some extent, although i've most of the time figured out my problems myself instead of calling on you more-than-able fellows to solve them.

    I'm going to first do that define thing, and see how it works.

    then i'm going to try and write a parser and a compiler that compiles into C++ then puts that through a command line compiler.

    this all should be very interesting.

    thanks alot for all of your ideas and suggestions, everyone.

  13. #13
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    And let me know if you get stuck on anything. I know I am technically a new coder ( 1 year ), but I love to program and I enjoy the problem-solving. Besides, it may help inspire me to move forward with writing that compiler I've been promising myself So keep me posted - eh?
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  14. #14
    Hmm... weird... I've been thinking of doing the same... I just never got started... If you need any help with syntax and stuff, mail me...

  15. #15
    Registered User billholm's Avatar
    Join Date
    Apr 2002
    Posts
    225

    Talking

    Here! Just posted a two-line post. Does
    this make you feel better? Hehehe.
    All men are created equal. But some are more equal than others.

    Visit me at http://www.angelfire.com/my/billholm

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. d programming language - a better c++?
    By kypronite in forum Tech Board
    Replies: 12
    Last Post: 02-28-2011, 02:55 AM
  2. What Language are you writing in?
    By C-Compiler in forum A Brief History of Cprogramming.com
    Replies: 22
    Last Post: 12-24-2008, 11:51 AM
  3. assembly language...the best tool for game programming?
    By silk.odyssey in forum Game Programming
    Replies: 50
    Last Post: 06-22-2004, 01:11 PM
  4. Language of choice after C++
    By gandalf_bar in forum A Brief History of Cprogramming.com
    Replies: 47
    Last Post: 06-15-2004, 01:20 AM
  5. Enough language discussions.
    By VirtualAce in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 06-13-2004, 09:59 AM