diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2000-09-12 21:07:18 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2000-09-12 21:07:18 +0000 |
commit | ed5003c58401e5727fcdd970505972394c95febb (patch) | |
tree | 53c25d5c65d6f7275f110503f51ab370e55af6ea /src/backend/parser/parser.c | |
parent | b5c0ab278bc67bc7f363da7d828a08ce7c4d28c2 (diff) | |
download | postgresql-ed5003c58401e5727fcdd970505972394c95febb.tar.gz postgresql-ed5003c58401e5727fcdd970505972394c95febb.zip |
First cut at full support for OUTER JOINs. There are still a few loose
ends to clean up (see my message of same date to pghackers), but mostly
it works. INITDB REQUIRED!
Diffstat (limited to 'src/backend/parser/parser.c')
-rw-r--r-- | src/backend/parser/parser.c | 66 |
1 files changed, 60 insertions, 6 deletions
diff --git a/src/backend/parser/parser.c b/src/backend/parser/parser.c index a7652407b73..4a6c825498a 100644 --- a/src/backend/parser/parser.c +++ b/src/backend/parser/parser.c @@ -1,32 +1,40 @@ /*------------------------------------------------------------------------- * * parser.c + * Main entry point/driver for PostgreSQL parser + * * * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.45 2000/04/12 17:15:27 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.46 2000/09/12 21:07:02 tgl Exp $ * *------------------------------------------------------------------------- */ #include "postgres.h" + +#include "nodes/parsenodes.h" +#include "nodes/pg_list.h" #include "parser/analyze.h" #include "parser/gramparse.h" +#include "parser/parse.h" #include "parser/parser.h" #include "parser/parse_expr.h" + #if defined(FLEX_SCANNER) extern void DeleteBuffer(void); - #endif /* FLEX_SCANNER */ char *parseString; /* the char* which holds the string to be * parsed */ List *parsetree; /* result of parsing is left here */ +static int lookahead_token; /* one-token lookahead */ +static bool have_lookahead; /* lookahead_token set? */ + #ifdef SETS_FIXED static void fixupsets(); static void define_sets(); @@ -42,11 +50,11 @@ parser(char *str, Oid *typev, int nargs) List *queryList; int yyresult; - init_io(); - - parseString = pstrdup(str); + parseString = str; parsetree = NIL; /* in case parser forgets to set it */ + have_lookahead = false; + scanner_init(); parser_init(typev, nargs); parse_expr_init(); @@ -83,6 +91,52 @@ parser(char *str, Oid *typev, int nargs) return queryList; } + +/* + * Intermediate filter between parser and base lexer (base_yylex in scan.l). + * + * The filter is needed because in some cases SQL92 requires more than one + * token lookahead. We reduce these cases to one-token lookahead by combining + * tokens here, in order to keep the grammar LR(1). + * + * Using a filter is simpler than trying to recognize multiword tokens + * directly in scan.l, because we'd have to allow for comments between the + * words ... + */ +int +yylex(void) +{ + int cur_token; + + /* Get next token --- we might already have it */ + if (have_lookahead) + { + cur_token = lookahead_token; + have_lookahead = false; + } + else + cur_token = base_yylex(); + + /* Do we need to look ahead for a possible multiword token? */ + switch (cur_token) + { + case UNION: + /* UNION JOIN must be reduced to a single UNIONJOIN token */ + lookahead_token = base_yylex(); + if (lookahead_token == JOIN) + cur_token = UNIONJOIN; + else + have_lookahead = true; + break; + + default: + break; + } + + return cur_token; +} + + #ifdef SETS_FIXED static void fixupsets(Query *parse) |