Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

syntax tree in yacc

Posted on 2008-10-15
2
Medium Priority
?
706 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
This article will show, step by step, how to integrate R code into a R Sweave document
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.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

604 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