diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2009-07-14 20:24:10 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2009-07-14 20:24:10 +0000 |
| commit | 1aa58d3a8389fcf8899745049f128f6b8fec7bc9 (patch) | |
| tree | 2e36e9cf65a517ce558fbfe694821da5bb28c131 /src/include/parser/gramparse.h | |
| parent | 0d4899e448df2b02434d6d423156408cde012707 (diff) | |
Tweak the core scanner so that it can be used by plpgsql too.
Changes:
Pass in the keyword lookup array instead of having it be hardwired.
(This incidentally allows elimination of some duplicate coding in ecpg.)
Re-order the token declarations in gram.y so that non-keyword tokens have
numbers that won't change when keywords are added or removed.
Add ".." and ":=" to the set of tokens recognized by scan.l. (Since these
combinations are nowhere legal in core SQL, this does not change anything
except the precise wording of the error you get when you write this.)
Diffstat (limited to 'src/include/parser/gramparse.h')
| -rw-r--r-- | src/include/parser/gramparse.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/include/parser/gramparse.h b/src/include/parser/gramparse.h index a8c2f407e4b..4b061e0504b 100644 --- a/src/include/parser/gramparse.h +++ b/src/include/parser/gramparse.h @@ -11,7 +11,7 @@ * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/parser/gramparse.h,v 1.46 2009/07/13 02:02:20 tgl Exp $ + * $PostgreSQL: pgsql/src/include/parser/gramparse.h,v 1.47 2009/07/14 20:24:10 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -20,6 +20,7 @@ #define GRAMPARSE_H #include "nodes/parsenodes.h" +#include "parser/keywords.h" /* * We track token locations in terms of byte offsets from the start of the @@ -50,6 +51,12 @@ typedef struct base_yy_extra_type Size scanbuflen; /* + * The keyword list to use. + */ + const ScanKeyword *keywords; + int num_keywords; + + /* * literalbuf is used to accumulate literal values when multiple rules * are needed to parse a single literal. Call startlit() to reset buffer * to empty, addlit() to add text. NOTE: the string in literalbuf is @@ -106,7 +113,10 @@ extern int filtered_base_yylex(YYSTYPE *lvalp, YYLTYPE *llocp, base_yyscan_t yyscanner); /* from scan.l */ -extern base_yyscan_t scanner_init(const char *str, base_yy_extra_type *yyext); +extern base_yyscan_t scanner_init(const char *str, + base_yy_extra_type *yyext, + const ScanKeyword *keywords, + int num_keywords); extern void scanner_finish(base_yyscan_t yyscanner); extern int base_yylex(YYSTYPE *lvalp, YYLTYPE *llocp, base_yyscan_t yyscanner); |
