Solved

syntax tree in yacc

Posted on 2008-10-15
2
677 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
The viewer will learn how to implement Singleton Design Pattern in Java.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…

726 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