lex & yacc question
Your pseudo-code has this:
/* Here I would like to create a node
of the tree and link it with the two
(supposed) nodes represented by each
of the "formula"'s .
e.g.(in a pseudo-code):
new_node.symbol="&";
new_node.left=$1;
new_node.right=$3;*/
which is approximately correct. But your c code doesn't do that:
formula: formula '&' formula { node leaf; /* only for testing: */
strcpy(leaf.symbol,"&");
leaf.left=$1;
leaf.right=$3;
You need to malloc() a new node and make sure it gets passed out
through $$. Your code is only updating the lexically scoped leaf,
which disappears at the close of the block.
--
William F. Dowling
Institute for Scientific Information
215-386-0100 x-1156
Reply to: