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