Related articles |
---|
yacc parse tree josh_adams@bmc.com (Josh Adams) (1998-12-10) |
Re: yacc parse tree simon.cozens@pembroke.oxford.ac.uk (Simon Cozens) (1998-12-13) |
Re: yacc parse tree mikesw@whiterose.net (1998-12-13) |
Re: yacc parse tree bob@werken.com (1998-12-18) |
Re: yacc parse tree belinfan@cs.utwente.nl (1998-12-18) |
Re: yacc parse tree josh_adams@bmc.com (Josh Adams) (1998-12-19) |
Re: yacc parse tree joachim.durchholz@munich.netsurf.de (Joachim Durchholz) (1998-12-19) |
[5 later articles] |
From: | Josh Adams <josh_adams@bmc.com> |
Newsgroups: | comp.compilers |
Date: | 10 Dec 1998 19:24:44 -0500 |
Organization: | Compilers Central |
Keywords: | yacc, question |
I'm implementing an SQL "where" clause. To this end, I modified the
SQL syntax checker in the O'Reilly Lex & Yacc book so that I have a
working where clause syntax checker. I imagine that I will need to
create some sort of parse tree consisting of nodes and leaves that
represent ands, ors, comparators, literals, column names, etc. Any
advice on how to do this? The book does not give an example of parse
tree implementation.
--
Josh Adams - BMC Software
josh_adams@bmc.com
[Yeah, I ran out of time and pages. Making a parse tree is actually
pretty simple. Each rule takes the subtrees from its subrules and
tokens and builds a tree for that rule and returns it as $$. When you
get to the top, you have a parse tree. The most annoying part is
allocating and deallocating the tree nodes, particularly if you want
to recover from parse errors. The old PCC compiler quite succesfully
used a static array of nodes which was big enough that in practice it
didn't run out. I've used a wrapped malloc that chains together all
of the allocated stuff, then run down the chain and free it all when
done. -John]
Return to the
comp.compilers page.
Search the
comp.compilers archives again.