]> granicus.if.org Git - postgresql/blob - src/backend/bootstrap/bootscanner.l
Rearrange backend startup sequence so that ShmemIndexLock can become
[postgresql] / src / backend / bootstrap / bootscanner.l
1 %{
2 /*-------------------------------------------------------------------------
3  *
4  * bootscanner.l
5  *        a lexical scanner for the bootstrap parser
6  *
7  * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  *
11  * IDENTIFICATION
12  *        $PostgreSQL: pgsql/src/backend/bootstrap/bootscanner.l,v 1.40 2005/06/29 22:51:54 tgl Exp $
13  *
14  *-------------------------------------------------------------------------
15  */
16 #include "postgres.h"
17
18 #include "access/attnum.h"
19 #include "access/htup.h"
20 #include "access/itup.h"
21 #include "access/skey.h"
22 #include "access/tupdesc.h"
23 #include "bootstrap/bootstrap.h"
24 #include "catalog/pg_am.h"
25 #include "catalog/pg_attribute.h"
26 #include "catalog/pg_class.h"
27 #include "nodes/nodes.h"
28 #include "nodes/parsenodes.h"
29 #include "nodes/pg_list.h"
30 #include "nodes/primnodes.h"
31 #include "parser/scansup.h"
32 #include "rewrite/prs2lock.h"
33 #include "storage/block.h"
34 #include "storage/fd.h"
35 #include "storage/itemptr.h"
36 #include "storage/off.h"
37 #include "utils/rel.h"
38
39 /* Not needed now that this file is compiled as part of bootparse. */
40 /* #include "bootstrap_tokens.h" */
41
42
43 /* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */
44 #undef fprintf
45 #define fprintf(file, fmt, msg)  ereport(ERROR, (errmsg_internal("%s", msg)))
46
47
48 static int      yyline = 1;                     /* line number for error reporting */
49
50 %}
51
52 %option 8bit
53 %option never-interactive
54 %option nodefault
55 %option nounput
56 %option noyywrap
57
58
59 D               [0-9]
60 oct             \\{D}{D}{D}
61 Exp             [Ee][-+]?{D}+
62 id              ([A-Za-z0-9_]|{oct}|\-)+
63 sid             \"([^\"])*\"
64 arrayid [A-Za-z0-9_]+\[{D}*\]
65
66 %%
67
68 open                    { return(OPEN); }
69
70 close                   { return(XCLOSE); }
71
72 create                  { return(XCREATE); }
73
74 OID                             { return(OBJ_ID); }
75 bootstrap               { return(XBOOTSTRAP); }
76 "shared_relation"       { return(XSHARED_RELATION); }
77 "without_oids"  { return(XWITHOUT_OIDS); }
78 _null_                  { return(NULLVAL); }
79
80 insert                  { return(INSERT_TUPLE); }
81
82 ","                             { return(COMMA); }
83 "="                             { return(EQUALS); }
84 "("                             { return(LPAREN); }
85 ")"                             { return(RPAREN); }
86
87 [\n]                    { yyline++; }
88 [\t]                    ;
89 " "                             ;
90
91 ^\#[^\n]* ; /* drop everything after "#" for comments */
92
93
94 "declare"               { return(XDECLARE); }
95 "build"                 { return(XBUILD); }
96 "indices"               { return(INDICES); }
97 "unique"                { return(UNIQUE); }
98 "index"                 { return(INDEX); }
99 "on"                    { return(ON); }
100 "using"                 { return(USING); }
101
102 {arrayid}               {
103                                         yylval.ival = EnterString(MapArrayTypeName((char*)yytext));
104                                         return(ID);
105                                 }
106 {id}                    {
107                                         char   *newid = scanstr((char*)yytext);
108                                         yylval.ival = EnterString(newid);
109                                         pfree(newid);
110                                         return(ID);
111                                 }
112 {sid}                   {
113                                         char   *newid;
114                                         yytext[strlen(yytext)-1] = '\0'; /* strip off quotes */
115                                         newid = scanstr((char*)yytext+1);
116                                         yylval.ival = EnterString(newid);
117                                         pfree(newid);
118                                         yytext[strlen(yytext)] = '"'; /* restore quotes */
119                                         return(ID);
120                                 }
121
122 (-)?{D}+"."{D}*({Exp})? |
123 (-)?{D}*"."{D}+({Exp})? |
124 (-)?{D}+{Exp}                   {
125                                                         yylval.ival = EnterString((char*)yytext);
126                                                         return(CONST_P);
127                                                 }
128
129 .                               {
130                                         elog(ERROR, "syntax error at line %d: unexpected character \"%s\"", yyline, yytext);
131                                 }
132
133
134
135 %%
136
137 void
138 yyerror(const char *message)
139 {
140         elog(ERROR, "%s at line %d", message, yyline);
141 }