]> granicus.if.org Git - postgresql/blob - src/backend/bootstrap/bootscanner.l
Lex/yacc source cleanup like indent.
[postgresql] / src / backend / bootstrap / bootscanner.l
1 %{
2 /*-------------------------------------------------------------------------
3  *
4  * bootscanner.lex--
5  *        a lexical scanner for the bootstrap parser
6  *
7  * Copyright (c) 1994, Regents of the University of California
8  *
9  *
10  * IDENTIFICATION
11  *        $Header: /cvsroot/pgsql/src/backend/bootstrap/bootscanner.l,v 1.7 1997/09/08 03:19:53 momjian Exp $
12  *
13  *-------------------------------------------------------------------------
14  */
15 #include <time.h>
16 #include <string.h>
17
18 #include "postgres.h"
19
20 #include "storage/block.h"
21 #include "storage/off.h"
22 #include "storage/itemptr.h"
23 #include "catalog/pg_attribute.h"
24 #include "access/attnum.h"
25 #include "nodes/pg_list.h"
26 #include "access/tupdesc.h"
27 #include "access/itup.h"
28 #include "access/funcindex.h"
29 #include "storage/fd.h"
30 #include "catalog/pg_am.h"
31 #include "catalog/pg_class.h"
32 #include "nodes/nodes.h"
33 #include "rewrite/prs2lock.h"
34 #include "access/skey.h"
35 #include "access/strat.h"
36 #include "utils/rel.h"
37 #include "bootstrap/bootstrap.h"
38
39 #include "nodes/primnodes.h"
40 #include "utils/nabstime.h"
41 #include "access/htup.h"
42 #include "utils/tqual.h"
43 #include "nodes/parsenodes.h"
44
45 #include "parser/scansup.h"
46
47 #include "bootstrap_tokens.h"
48
49 #define                 YY_NO_UNPUT
50
51 /* some versions of lex define this as a macro */
52 #if defined(yywrap)
53 #undef yywrap
54 #endif /* yywrap */
55
56 YYSTYPE yylval;
57 int             yyline;  /* keep track of the line number for error reporting */
58
59 %}
60
61 D               [0-9]
62 oct             \\{D}{D}{D}
63 Exp             [Ee][-+]?{D}+
64 id              ([A-Za-z0-9_]|{oct}|\-)+
65 sid             \"([^\"])*\"
66 arrayid [A-Za-z0-9_]+\[{D}*\]
67
68 %%
69
70 open                    { return(OPEN); }
71
72 close                   { return(XCLOSE); }
73
74 create                  { return(XCREATE); }
75
76 OID                             { return(OBJ_ID); }
77 bootstrap               { return(XBOOTSTRAP); }
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 "index"                 { return(INDEX); }
98 "on"                    { return(ON); }
99 "using"                 { return(USING); }
100 {arrayid}               {
101                                         yylval.ival = EnterString(MapArrayTypeName((char*)yytext));
102                                         return(ID);
103                                 }
104 {id}                    {
105                                         yylval.ival = EnterString(scanstr((char*)yytext));
106                                         return(ID);
107                                 }
108 {sid}                   {
109                                         yytext[strlen(yytext)-1] = '\0'; /* strip off quotes */
110                                         yylval.ival = EnterString(scanstr((char*)yytext+1));
111                                         yytext[strlen(yytext)] = '"'; /* restore quotes */
112                                         return(ID);
113                                 }
114
115 (-)?{D}+"."{D}*({Exp})? |
116 (-)?{D}*"."{D}+({Exp})? |
117 (-)?{D}+{Exp}                   {
118                                                         yylval.ival = EnterString((char*)yytext);
119                                                         return(CONST);
120                                                 }
121
122 .                               {
123                                         printf("syntax error %d : -> %s\n", yyline, yytext);
124                                 }
125
126
127
128 %%
129
130 int
131 yywrap(void)
132 {
133         return 1;
134 }
135
136 void
137 yyerror(const char *str)
138 {
139         fprintf(stderr,"\tsyntax error %d : %s",yyline, str);
140 }