• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 714
  • Last Modified:

syntax tree in yacc

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
kuntilanak
Asked:
kuntilanak
1 Solution
 
Infinity08Commented:
>> 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
 
kuntilanakAuthor Commented:
I already found a C- one! thanks though
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now