2 /*-------------------------------------------------------------------------
5 * a lexical scanner for the bootstrap parser
7 * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
14 *-------------------------------------------------------------------------
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"
39 /* Not needed now that this file is compiled as part of bootparse. */
40 /* #include "bootparse.h" */
43 /* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */
45 #define fprintf(file, fmt, msg) ereport(ERROR, (errmsg_internal("%s", msg)))
48 static int yyline = 1; /* line number for error reporting */
53 %option never-interactive
58 %option prefix="boot_yy"
64 id ([A-Za-z0-9_]|{oct}|\-)+
66 arrayid [A-Za-z0-9_]+\[{D}*\]
70 open { return(OPEN); }
72 close { return(XCLOSE); }
74 create { return(XCREATE); }
76 OID { return(OBJ_ID); }
77 bootstrap { return(XBOOTSTRAP); }
78 "shared_relation" { return(XSHARED_RELATION); }
79 "without_oids" { return(XWITHOUT_OIDS); }
80 _null_ { return(NULLVAL); }
82 insert { return(INSERT_TUPLE); }
84 "," { return(COMMA); }
85 "=" { return(EQUALS); }
86 "(" { return(LPAREN); }
87 ")" { return(RPAREN); }
93 ^\#[^\n]* ; /* drop everything after "#" for comments */
96 "declare" { return(XDECLARE); }
97 "build" { return(XBUILD); }
98 "indices" { return(INDICES); }
99 "unique" { return(UNIQUE); }
100 "index" { return(INDEX); }
102 "using" { return(USING); }
103 "toast" { return(XTOAST); }
106 yylval.ival = EnterString(MapArrayTypeName((char*)yytext));
110 char *newid = scanstr((char*)yytext);
111 yylval.ival = EnterString(newid);
117 yytext[strlen(yytext)-1] = '\0'; /* strip off quotes */
118 newid = scanstr((char*)yytext+1);
119 yylval.ival = EnterString(newid);
121 yytext[strlen(yytext)] = '"'; /* restore quotes */
125 (-)?{D}+"."{D}*({Exp})? |
126 (-)?{D}*"."{D}+({Exp})? |
128 yylval.ival = EnterString((char*)yytext);
133 elog(ERROR, "syntax error at line %d: unexpected character \"%s\"", yyline, yytext);
141 yyerror(const char *message)
143 elog(ERROR, "%s at line %d", message, yyline);