Re: Abstract Syntax Trees - binary tree or other, which is best?

Joachim Pimiskern <Joachim.Pimiskern@de.bosch.com>
8 Oct 2000 22:15:24 -0400

          From comp.compilers

Related articles
Abstract Syntax Trees - binary tree or other, which is best? ed_davis@my-deja.com (Ed Davis) (2000-10-01)
Re: Abstract Syntax Trees - binary tree or other, which is best? Joachim.Pimiskern@de.bosch.com (Joachim Pimiskern) (2000-10-08)
Re: Abstract Syntax Trees - binary tree or other, which is best? thp@roam-thp2.cs.ucr.edu (Tom Payne) (2000-10-08)
| List of all articles for this month |
From: Joachim Pimiskern <Joachim.Pimiskern@de.bosch.com>
Newsgroups: comp.compilers
Date: 8 Oct 2000 22:15:24 -0400
Organization: Robert Bosch GmbH
References: 00-10-011
Keywords: AST

Hello Ed,


Ed Davis schrieb:
> I have read a couple of texts where the author recommends using a
> binary tree for the abstract syntax tree. In many other texts, non-
> binary trees are used, with the tree being tailored to what is being
> stored at the time.


Which data structure one should use depends on the syntactical
structure of the language being parsed. The data structure of an AST
should reflect the language. In one of my projects where I had to
expand macros in C files it was sufficient to hold a hash table under
one big root object.


Binary trees are usually used to store key-value pairs like constants
and their content, variables and their values, functions and their
context / code, but in some cases hash tables allow faster retrieval.


HTH,
Joachim


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.