Algebraic Parser

Discussion in 'C++' started by DennisNedry, Feb 2, 2005.

  1. DennisNedry

    DennisNedry Guest

    Any general ideas on techniques for creating parsers for algebraic and
    linear equations?
     
    DennisNedry, Feb 2, 2005
    #1
    1. Advertising

  2. DennisNedry wrote:
    > Any general ideas on techniques for creating parsers for algebraic and
    > linear equations?


    Yes. Create them. Any particular C++ language questions?
     
    Victor Bazarov, Feb 2, 2005
    #2
    1. Advertising

  3. "DennisNedry" <> wrote in message
    news:...
    > Any general ideas on techniques for creating parsers for algebraic and
    > linear equations?


    Some C++ (or C) tools that can help generate parsers include:
    - Flex http://www.gnu.org/software/flex/
    A good old proven solution for generating parsing code/tables.
    - Boost::spirit http://www.boost.org/libs/spirit/
    A template based solution (no separate code generation)
    - ANTLR http://www.antlr.org/
    Also a popular generator (for C++ & more), but I never used it.
    Of course, hand-coding is possible as well, all depends on
    the complexity of what you are trying to do.

    hth -Ivan
    --
    http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
     
    Ivan Vecerina, Feb 2, 2005
    #3
  4. DennisNedry

    DennisNedry Guest

    Okay. Is there a more efficient way to parse this data (in C++) than
    doing character comparisons on the entire user input such as:

    for(char='A';char<='Z';char++){
    for(i=0;user_input!=NULL;i++){
    if(user_input==char){

    and then dumping the matches into a variable in a structure?
    Sorry if this is a dumb question, I'm relatively new to C++.
     
    DennisNedry, Feb 2, 2005
    #4
  5. DennisNedry

    Jeff Flinn Guest

    Ivan Vecerina wrote:
    > "DennisNedry" <> wrote in message
    > news:...
    >> Any general ideas on techniques for creating parsers for algebraic
    >> and linear equations?

    >
    > Some C++ (or C) tools that can help generate parsers include:
    > - Flex http://www.gnu.org/software/flex/
    > A good old proven solution for generating parsing code/tables.
    > - Boost::spirit http://www.boost.org/libs/spirit/
    > A template based solution (no separate code generation)


    Which has examples of doing exactly what you're asking for.

    Jeff
     
    Jeff Flinn, Feb 2, 2005
    #5
  6. DennisNedry wrote:
    > Okay. Is there a more efficient way to parse this data (in C++) than
    > doing character comparisons on the entire user input such as:
    >
    > for(char='A';char<='Z';char++){
    > for(i=0;user_input!=NULL;i++){
    > if(user_input==char){
    >
    > and then dumping the matches into a variable in a structure?
    > Sorry if this is a dumb question, I'm relatively new to C++.


    What books are you reading? If you are interested in expression
    parsing, chapter 6 of "The C++ Programming Language" by Stroustrup
    has a good example of that.

    V
     
    Victor Bazarov, Feb 2, 2005
    #6
  7. DennisNedry

    DennisNedry Guest

    Okay, thanks. I'll check that out.
     
    DennisNedry, Feb 2, 2005
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mike Wahler
    Replies:
    1
    Views:
    397
    Razmig K
    Apr 1, 2004
  2. Michel Rosien
    Replies:
    0
    Views:
    367
    Michel Rosien
    Apr 22, 2004
  3. steve
    Replies:
    3
    Views:
    273
    Paul Boddie
    Oct 23, 2006
  4. DavidM
    Replies:
    6
    Views:
    575
  5. Cristian
    Replies:
    9
    Views:
    579
    Victor Bazarov
    Aug 23, 2007
Loading...

Share This Page