Does lex+yacc produce a tree data structure that is easy for anexternal C++ program to examine and m

Discussion in 'C++' started by Robert, Apr 14, 2008.

  1. Robert

    Robert Guest

    If the goal is to take a 1-dimensional package of text and produce a
    tree data structure that is easy to understand and manipulate, and
    then write C/C++ code that works with that tree - does lex/yacc suit
    that purpose - i.e. kind of like a tree-manufacturing C library? Or is
    it for producing a compiler/interpreter the internals of which a new C/
    C++ program cannot so easily work with?
    Robert, Apr 14, 2008
    #1
    1. Advertising

  2. Re: Does lex+yacc produce a tree data structure that is easy for an external C++ program to examine and manipulate?

    Robert <> writes:

    > If the goal is to take a 1-dimensional package of text and produce a
    > tree data structure that is easy to understand and manipulate, and
    > then write C/C++ code that works with that tree - does lex/yacc suit
    > that purpose - i.e. kind of like a tree-manufacturing C library? Or is
    > it for producing a compiler/interpreter the internals of which a new C/
    > C++ program cannot so easily work with?


    It's not lex or yacc that would build such a tree, but the action code
    you would add to your grammar file, compiled by yacc, that would have
    to do it.

    I don't know about yacc, but bison can generate C++ parsers, so you
    should be able to put easily C++ code in the actions to build your
    tree of objects.

    With yacc, if you're restricted to C, you can still call from each
    action a C function that could be implemented in C++.

    In any case, it's not done automatically by yacc or bison, you will
    have to write the grammar and the action code to build the tree.

    --
    __Pascal Bourguignon__
    Pascal J. Bourguignon, Apr 14, 2008
    #2
    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. Moonlit

    Best lex/yacc for C++?

    Moonlit, Oct 8, 2003, in forum: C++
    Replies:
    18
    Views:
    1,545
    Moonlit
    Oct 14, 2003
  2. Arthur T. Murray

    Re: Parsing English with lex and yacc

    Arthur T. Murray, Jan 23, 2004, in forum: C++
    Replies:
    5
    Views:
    1,323
    Amnon Meyers
    Jan 26, 2004
  3. cylin
    Replies:
    1
    Views:
    425
    Ben Pfaff
    Jan 7, 2004
  4. Gvs

    lex and yacc

    Gvs, May 11, 2005, in forum: C Programming
    Replies:
    3
    Views:
    486
    T.M. Sommers
    May 12, 2005
  5. Lex/Yacc and multiple input files

    , May 18, 2007, in forum: C Programming
    Replies:
    2
    Views:
    422
    SM Ryan
    May 19, 2007
Loading...

Share This Page