Solved

syntax tree in yacc

Posted on 2008-10-15
2
672 Views
Last Modified: 2013-11-18
can someone give me an implementation of how to build a syntax tree of a parser in yacc  for a simple language, such as C-?
0
Comment
Question by:kuntilanak
2 Comments
 
LVL 53

Accepted Solution

by:
Infinity08 earned 500 total points
ID: 22728927
>> or a simple language, such as C-?

First of all : C is not a simple language when it comes to writing a parser for it ;) Especially not if the parse tree will be used in a C compiler.

If you want an existing implementation, I suggest taking a look at the gcc compiler source. I warn you though : it might overwhelm you ;)

It's probably better to start with a real easy language, like a simple calculator that only understands the 4 basic operations (addition, subtraction, multiplication, division), and only works on integers.
It is a standard exercise to get familiar with building parsers, but for a very good reason. It will teach you a lot about the pitfalls and specifics of writing parsers.

Here's a simple example :

        http://www.cs.man.ac.uk/~pjj/cs2121/ho/node4.html
0
 

Author Comment

by:kuntilanak
ID: 22731186
I already found a C- one! thanks though
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Better understanding on C++ Class serialization and formats 9 59
C++ question 3 61
split53 challenge 7 77
mapAB Challlenge 35 123
Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now