Thread: Compiling with C++

  1. #1
    Registered User
    Join Date
    Aug 2004
    Posts
    731

    Compiling with C++

    Well I know I am not ready to you guys, but I belive I am.

    I want to make a program that can at first recognize c++ (counsle) functions that are in variables.

    What I mean is I put like, lets say, cout<<"Hello"; in a variable and then the program would know what to do.

    Then I want to make the priogram able to make anouther c++ program but does the actions in the variables in the order they are in.

    I have no clue were to start this.


    Thanks alot!

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    sounds like you're wanting to make a C++ interpreter. basically you just split the text into tokens, lookup the appropriate function pointer, then marshall the parameters to the function.
    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;
    }

  3. #3
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    well ok, but now the looking up part is the hard thing.

    I looked on google and found nothing but the characters that c++ uses.

    Could someone help me maybe get a site on this or somthing?

  4. #4
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    >> I looked on google and found nothing but the characters that c++ uses.

    well, looking at my keyboard I see a total of two characters that c++ *doesn't* use('`' and '@') - so pretty much everything has to be expected by your scanner. also you'll have to differentiate between tokens like + and ++, etc - you might google on some working lexical scanner implementations to begin with.
    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
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    C++ is an extremely complicated language to parse. You should look into an alternative approach to whatever your problem is.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  6. #6
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    lol well I wasn't looking for the whole lang. to fit into the program.

    But I also was gonig to cram it into a dll.

    And I will try some other time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling Issues
    By pc_doctor in forum C Programming
    Replies: 3
    Last Post: 11-30-2007, 10:00 AM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. Problem Compiling
    By Flakster in forum C++ Programming
    Replies: 4
    Last Post: 06-13-2006, 01:09 AM
  4. Compiling
    By Dae in forum C++ Programming
    Replies: 7
    Last Post: 06-15-2005, 01:08 AM
  5. compiling and executing issue with lcc win32
    By GanglyLamb in forum C Programming
    Replies: 10
    Last Post: 12-22-2004, 02:24 PM