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

R

Robert

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?
 
P

Pascal J. Bourguignon

Robert said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top