Solved

syntax tree in yacc

Posted on 2008-10-15
2
675 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C++ Language error 28 242
Problem to page 4 93
NEED HELP WITH VISUAL STUDIO 2017 (beginner) 6 65
Adding items to a C# list incrementally 5 28
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…
This article will show, step by step, how to integrate R code into a R Sweave document
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 goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

791 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