1996-07-09 08:22:35 +02:00
|
|
|
%{
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* bootscanner.lex--
|
1997-09-08 05:20:18 +02:00
|
|
|
* a lexical scanner for the bootstrap parser
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
* Copyright (c) 1994, Regents of the University of California
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* IDENTIFICATION
|
1997-11-24 06:09:50 +01:00
|
|
|
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootscanner.l,v 1.8 1997/11/24 05:07:56 momjian Exp $
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
1996-10-23 09:42:13 +02:00
|
|
|
#include <time.h>
|
1997-01-10 21:19:49 +01:00
|
|
|
#include <string.h>
|
1996-10-23 09:42:13 +02:00
|
|
|
|
1996-08-28 09:27:54 +02:00
|
|
|
#include "postgres.h"
|
1996-10-21 10:31:23 +02:00
|
|
|
|
|
|
|
#include "storage/block.h"
|
|
|
|
#include "storage/off.h"
|
|
|
|
#include "storage/itemptr.h"
|
|
|
|
#include "catalog/pg_attribute.h"
|
|
|
|
#include "access/attnum.h"
|
|
|
|
#include "nodes/pg_list.h"
|
|
|
|
#include "access/tupdesc.h"
|
|
|
|
#include "access/itup.h"
|
|
|
|
#include "access/funcindex.h"
|
|
|
|
#include "storage/fd.h"
|
|
|
|
#include "catalog/pg_am.h"
|
|
|
|
#include "catalog/pg_class.h"
|
1997-09-08 05:20:18 +02:00
|
|
|
#include "nodes/nodes.h"
|
1996-10-21 10:31:23 +02:00
|
|
|
#include "rewrite/prs2lock.h"
|
|
|
|
#include "access/skey.h"
|
|
|
|
#include "access/strat.h"
|
|
|
|
#include "utils/rel.h"
|
1996-07-09 08:22:35 +02:00
|
|
|
#include "bootstrap/bootstrap.h"
|
1996-10-21 10:31:23 +02:00
|
|
|
|
|
|
|
#include "nodes/primnodes.h"
|
|
|
|
#include "utils/nabstime.h"
|
1997-09-08 05:20:18 +02:00
|
|
|
#include "access/htup.h"
|
1996-10-21 10:31:23 +02:00
|
|
|
#include "nodes/parsenodes.h"
|
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
#include "parser/scansup.h"
|
|
|
|
|
|
|
|
#include "bootstrap_tokens.h"
|
|
|
|
|
1997-09-08 05:20:18 +02:00
|
|
|
#define YY_NO_UNPUT
|
1996-10-23 09:42:13 +02:00
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
/* some versions of lex define this as a macro */
|
|
|
|
#if defined(yywrap)
|
|
|
|
#undef yywrap
|
|
|
|
#endif /* yywrap */
|
|
|
|
|
1997-09-08 05:20:18 +02:00
|
|
|
YYSTYPE yylval;
|
|
|
|
int yyline; /* keep track of the line number for error reporting */
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
%}
|
|
|
|
|
1997-09-08 05:20:18 +02:00
|
|
|
D [0-9]
|
|
|
|
oct \\{D}{D}{D}
|
|
|
|
Exp [Ee][-+]?{D}+
|
|
|
|
id ([A-Za-z0-9_]|{oct}|\-)+
|
|
|
|
sid \"([^\"])*\"
|
|
|
|
arrayid [A-Za-z0-9_]+\[{D}*\]
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
%%
|
|
|
|
|
1997-09-08 05:20:18 +02:00
|
|
|
open { return(OPEN); }
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-09-08 05:20:18 +02:00
|
|
|
close { return(XCLOSE); }
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-09-08 05:20:18 +02:00
|
|
|
create { return(XCREATE); }
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-09-08 05:20:18 +02:00
|
|
|
OID { return(OBJ_ID); }
|
|
|
|
bootstrap { return(XBOOTSTRAP); }
|
|
|
|
_null_ { return(NULLVAL); }
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-09-08 05:20:18 +02:00
|
|
|
insert { return(INSERT_TUPLE); }
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-09-08 05:20:18 +02:00
|
|
|
"," { return(COMMA); }
|
|
|
|
"=" { return(EQUALS); }
|
|
|
|
"(" { return(LPAREN); }
|
|
|
|
")" { return(RPAREN); }
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-09-08 05:20:18 +02:00
|
|
|
[\n] { yyline++; }
|
|
|
|
[\t] ;
|
|
|
|
" " ;
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
^\#[^\n]* ; /* drop everything after "#" for comments */
|
|
|
|
|
|
|
|
|
1997-09-08 05:20:18 +02:00
|
|
|
"declare" { return(XDECLARE); }
|
|
|
|
"build" { return(XBUILD); }
|
|
|
|
"indices" { return(INDICES); }
|
|
|
|
"index" { return(INDEX); }
|
|
|
|
"on" { return(ON); }
|
|
|
|
"using" { return(USING); }
|
|
|
|
{arrayid} {
|
|
|
|
yylval.ival = EnterString(MapArrayTypeName((char*)yytext));
|
|
|
|
return(ID);
|
|
|
|
}
|
|
|
|
{id} {
|
|
|
|
yylval.ival = EnterString(scanstr((char*)yytext));
|
|
|
|
return(ID);
|
|
|
|
}
|
|
|
|
{sid} {
|
|
|
|
yytext[strlen(yytext)-1] = '\0'; /* strip off quotes */
|
|
|
|
yylval.ival = EnterString(scanstr((char*)yytext+1));
|
|
|
|
yytext[strlen(yytext)] = '"'; /* restore quotes */
|
|
|
|
return(ID);
|
|
|
|
}
|
|
|
|
|
|
|
|
(-)?{D}+"."{D}*({Exp})? |
|
|
|
|
(-)?{D}*"."{D}+({Exp})? |
|
|
|
|
(-)?{D}+{Exp} {
|
|
|
|
yylval.ival = EnterString((char*)yytext);
|
|
|
|
return(CONST);
|
|
|
|
}
|
|
|
|
|
|
|
|
. {
|
|
|
|
printf("syntax error %d : -> %s\n", yyline, yytext);
|
|
|
|
}
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%%
|
|
|
|
|
1996-10-23 09:42:13 +02:00
|
|
|
int
|
|
|
|
yywrap(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 05:20:18 +02:00
|
|
|
return 1;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
1996-10-23 09:42:13 +02:00
|
|
|
void
|
|
|
|
yyerror(const char *str)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 05:20:18 +02:00
|
|
|
fprintf(stderr,"\tsyntax error %d : %s",yyline, str);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|