[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Parse Trees and Bison
From: |
Hans Aberg |
Subject: |
Re: Parse Trees and Bison |
Date: |
Fri, 23 Apr 2004 01:42:39 +0200 |
At 13:15 -0400 2004/04/22, address@hidden wrote:
>I'm trying to understand the best way by adding C functions to my BISON
>grammer file to being able to generate a syntax tree of my source code.
...
>Then going back up the stack, where do I create the nodes for my syntax
>tree?
You merely create rules like:
a: a_1 ... a_k { $$ = (node("a"), branches($1, ..., $k) }
i.e., you build
"a"
/ ... \
t_1 t_k
where t_i is the tree of a_i.
The lexer (typically generated by Flex) will produce the leaf values to the
$i values.
Hans Aberg