Thread: How to create a script interpreter using C++

  1. #16
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    While I don't have any experience with them myself (the only scripting language I wrote, I wrote the parser, pseudo-code compiler, interpreter at al from scratch), learning the tools Yacc and Bison might help with some of the chores and save you from some grudge work. Having done this before I would like to ask: have you documented or at least specified your language API yet or are you just sort of generally in love with the idea of writing a scripted language interpreter? I ask because unless you have done the former, the latter will be pretty difficult to make and not be a brittle program...
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  2. #17
    Registered User Kudose's Avatar
    Join Date
    Jun 2006
    Posts
    92
    I have not proceeded to document anything yet. I was waiting to learn a little more about the process and tools available. I have a good idea of what syntax and features (dynamic typing, object support) I would like to be supported. Obviously writing an object oriented language is not an easy task, but I could learn/figure out how to do it by learning how to create a procedural language. Thank you for more suggestions on tools to use. I will look into them.
    IDE + Complier: Code::Blocks w/ GCC
    PC: AMD Phenom x4 2.2Ghz w/ 8G RAM
    OSes: CentOS 6.2 x64 & Win 7 Ultimate x64

  3. #18
    Registered User Kudose's Avatar
    Join Date
    Jun 2006
    Posts
    92
    Useful link: The LEX & YACC Page
    IDE + Complier: Code::Blocks w/ GCC
    PC: AMD Phenom x4 2.2Ghz w/ 8G RAM
    OSes: CentOS 6.2 x64 & Win 7 Ultimate x64

  4. #19
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    There's a bunch of links here -> Bloodshed Software - Compilers resources
    Don't know if any are stale or not (but google might find new locations).
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #20
    Registered User Kudose's Avatar
    Join Date
    Jun 2006
    Posts
    92
    Quote Originally Posted by jeffcobb View Post
    While I don't have any experience with them myself (the only scripting language I wrote, I wrote the parser, pseudo-code compiler, interpreter at al from scratch)
    Would you allow any of this code to be previewed?
    IDE + Complier: Code::Blocks w/ GCC
    PC: AMD Phenom x4 2.2Ghz w/ 8G RAM
    OSes: CentOS 6.2 x64 & Win 7 Ultimate x64

  6. #21
    Registered User
    Join Date
    May 2009
    Posts
    242
    While I've got a long way to go before being ready to try something like that (definitely an interesting thing to try!), I just ran an amazon book search on "compiler" and came up with a LOT of literature. No idea what the best of it is, but the newest I found was: Michael Scott, Programming Language Pragmatics, 3rd ed. 2009. Also Alfred Aho et al., Compilers: Principles, Techniques and Tools looks like it's gone through several printings and probably has some good material.

  7. #22
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by Aisthesis View Post
    Michael Scott, Programming Language Pragmatics, 3rd ed. 2009.
    That book seems to focus more on the design of languages, not compiler implementations, and could be a good reference. I haven't read it.

    Also Alfred Aho et al., Compilers: Principles, Techniques and Tools looks like it's gone through several printings and probably has some good material.
    This is the Dragon Book.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  8. #23
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    Quote Originally Posted by Kudose View Post
    Would you allow any of this code to be previewed?
    Sorry, its IP belonging to a previous employer. Wish I could; I invented/wrote some neat stuff for that guy and would love to leverage some of the other things I did for him too...and I know its just sitting on a hard drive somewhere being ignored ATM...

    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  9. #24
    Registered User
    Join Date
    Jul 2007
    Posts
    15

  10. #25
    Registered User Kudose's Avatar
    Join Date
    Jun 2006
    Posts
    92
    Quote Originally Posted by curt22 View Post
    Thanks!
    IDE + Complier: Code::Blocks w/ GCC
    PC: AMD Phenom x4 2.2Ghz w/ 8G RAM
    OSes: CentOS 6.2 x64 & Win 7 Ultimate x64

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 04-10-2009, 12:57 AM
  2. using expect script in C program
    By nitinmhetre in forum Linux Programming
    Replies: 1
    Last Post: 12-21-2006, 08:25 AM
  3. How to create a file association program?
    By eShain in forum Windows Programming
    Replies: 1
    Last Post: 03-06-2006, 12:15 PM
  4. In a game Engine...
    By Shamino in forum Game Programming
    Replies: 28
    Last Post: 02-19-2006, 11:30 AM
  5. Cannot create MDI Client Win
    By JaWiB in forum Windows Programming
    Replies: 1
    Last Post: 10-31-2005, 10:05 PM