| Lists: | pgsql-hackers |
|---|
| From: | "Bin Liu" <bliu(at)ece(dot)gatech(dot)edu> |
|---|---|
| To: | <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Question about Parser() |
| Date: | 2004-10-11 22:13:43 |
| Message-ID: | [email protected] |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-hackers |
Can somebody explain how the 'parsetree' in the parser( ) function get populated? What I saw is just a NIL. And it is not touched else where in this file.
This file is src/backend/parser/parser.c
Thanks!
Bin
/*
* parser
* Given a query in string form, and optionally info about
* parameter types, do lexical and syntactic analysis.
*
* Returns a list of raw (un-analyzed) parse trees.
*/
List *
parser(StringInfo str, Oid *typev, int nargs)
{
int yyresult;
parsetree = NIL; /* in case parser forgets to set it */
have_lookahead = false;
scanner_init(str);
parser_init();
parse_expr_init();
parser_param_set(typev, nargs);
yyresult = yyparse();
scanner_finish();
clearerr(stdin);
if (yyresult) /* error */
return NIL;
return parsetree;
}
| From: | Neil Conway <neilc(at)samurai(dot)com> |
|---|---|
| To: | Bin Liu <bliu(at)ece(dot)gatech(dot)edu> |
| Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: Question about Parser() |
| Date: | 2004-10-13 04:05:53 |
| Message-ID: | [email protected] |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-hackers |
On Tue, 2004-10-12 at 08:13, Bin Liu wrote:
> Can somebody explain how the 'parsetree' in the parser( ) function get
> populated? What I saw is just a NIL. And it is not touched else where
> in this file.
"parsetree" is a global variable; it is defined in parser.c, but
declared (via extern) in gram.y. gram.y constructs the parsetree (via
yacc) and delivers the raw parsetree back to parser() by assigning to
"parsetree" (see the "stmtblock" production in gram.y, for example).
-Neil