]> granicus.if.org Git - postgresql/blob - src/backend/bootstrap/bootscanner.l
Major code cleanups from D'arcy (-Wall -Werror)
[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.4 1996/10/23 07:39:39 scrappy Exp $
12  *
13  *-------------------------------------------------------------------------
14  */
15 #include <time.h>
16
17 #include "postgres.h"
18
19 #include "storage/block.h"
20 #include "storage/off.h"
21 #include "storage/itemptr.h"
22 #include "catalog/pg_attribute.h"
23 #include "access/attnum.h"
24 #include "nodes/pg_list.h"
25 #include "access/tupdesc.h"
26 #include "access/itup.h"
27 #include "access/funcindex.h"
28 #include "storage/fd.h"
29 #include "catalog/pg_am.h"
30 #include "catalog/pg_class.h"
31 #include "nodes/nodes.h"  
32 #include "rewrite/prs2lock.h"
33 #include "access/skey.h"
34 #include "access/strat.h"
35 #include "utils/rel.h"
36 #include "bootstrap/bootstrap.h"
37
38 #include "nodes/primnodes.h"
39 #include "utils/nabstime.h"
40 #include "access/htup.h"  
41 #include "utils/tqual.h"
42 #include "nodes/parsenodes.h"
43
44 #include "parser/scansup.h"
45
46 #include "bootstrap_tokens.h"
47
48 #define         YY_NO_UNPUT
49
50 /* some versions of lex define this as a macro */
51 #if defined(yywrap)
52 #undef yywrap
53 #endif /* yywrap */
54
55 YYSTYPE yylval;
56 int     yyline;  /* keep track of the line number for error reporting */
57
58 %}
59
60 D       [0-9]
61 oct     \\{D}{D}{D}
62 Exp     [Ee][-+]?{D}+
63 id      ([A-Za-z0-9_]|{oct}|\-)+
64 sid     \"([^\"])*\"
65 arrayid [A-Za-z0-9_]+\[{D}*\]
66
67 %%
68
69 open            { return(OPEN); }
70
71 close           { return(XCLOSE); }
72
73 create          { return(XCREATE); }
74
75 OID             { return(OBJ_ID); }
76 bootstrap       { return(XBOOTSTRAP); }
77 _null_          { return(NULLVAL); }
78
79 insert          { return(INSERT_TUPLE); }
80
81 ","             { return(COMMA); }
82 "="             { return(EQUALS); }
83 "("             { return(LPAREN); }
84 ")"             { return(RPAREN); }
85
86 [\n]            { yyline++; }
87 [\t]            ;
88 " "             ; 
89
90 ^\#[^\n]* ; /* drop everything after "#" for comments */
91
92
93 "declare"       { return(XDECLARE); }
94 "build"         { return(XBUILD); }
95 "indices"       { return(INDICES); }
96 "index"         { return(INDEX); }
97 "on"            { return(ON); }
98 "using"         { return(USING); }
99 {arrayid}       {
100                     yylval.ival = EnterString(MapArrayTypeName((char*)yytext));
101                     return(ID);
102                 }
103 {id}            { 
104                     yylval.ival = EnterString(scanstr((char*)yytext));
105                     return(ID);
106                 }
107 {sid}           {
108                     yylval.ival = EnterString(scanstr((char*)yytext));
109                     return(ID);
110                 }
111
112 (-)?{D}+"."{D}*({Exp})? |
113 (-)?{D}*"."{D}+({Exp})? |
114 (-)?{D}+{Exp}           {
115                             yylval.ival = EnterString((char*)yytext);
116                             return(CONST);
117                         }
118
119 .               {
120                     printf("syntax error %d : -> %s\n", yyline, yytext);
121                 }
122
123
124
125 %%
126
127 int
128 yywrap(void)
129 {
130     return 1;
131 }
132
133 void
134 yyerror(const char *str)
135 {
136     fprintf(stderr,"\tsyntax error %d : %s",yyline, str);
137 }