473,499 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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?
Jun 27 '08 #1
1 2005
Robert <ir*********@gmail.comwrites:
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__
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
10711
by: Moonlit | last post by:
Hi, I am searching for the best lex and yacc combination (or something similar) that can be used in combination with C++ and that can contain C++ code. I have the regular flex/bison port working...
1
4764
by: EKEY | last post by:
Hello, sorry this is not a qt-related question. I need the C++ grammar ( .y file and .l file) in Lex/Yacc source. Could someone help me ? Thanks EKEY
7
12030
by: macabstract | last post by:
does anyone know of a "reasonably practical" yacc-type parser for JavaScript? in the absence of one, i will endevour to write my own starting from the BNF specification: ...
0
1213
by: deltaa5 | last post by:
hi. i need a source code compute logical expressions in lex/yacc. for Example: (20>5) or (6<=6)--->true (1<=2) and (3==1) --->false.
2
2390
by: Baron Samedi | last post by:
I have been looking around for an editor which edit serialised files (as created with the PHP function serialize()), but can't find one, so I have decided to code my own. I can either hand code...
1
2412
by: ajaxjinx | last post by:
%token NUMBER %token LETTER %start cmd %%
13
4983
by: Berk Birand | last post by:
Hi, I am working on a school project where we use lex/yacc to write a compiler for a fictional (Java-like) language. I have handled all the details about the yacc and lex files, but I still have...
2
1717
by: Xose Lois Castro | last post by:
Hi, mates: I'm trying to write a grammar to read files with the following structure, for example: text ... more text
1
5161
by: mh | last post by:
I'm porting a C lex/yacc based project, and would like to redo it in python. What's the best option for a python lex/yacc-like? I've googled a few things, but wanted to see the current...
0
7128
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7169
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6892
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7385
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5467
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3096
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1425
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
294
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.