bootscanner.l 2.09 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
%{
/*-------------------------------------------------------------------------
 *
 * bootscanner.lex--
 *    a lexical scanner for the bootstrap parser
 *
 * Copyright (c) 1994, Regents of the University of California
 *
 *
 * IDENTIFICATION
11
 *    $Header: /cvsroot/pgsql/src/backend/bootstrap/bootscanner.l,v 1.2 1996/08/28 07:14:09 scrappy Exp $
12 13 14
 *
 *-------------------------------------------------------------------------
 */
15
#include "postgres.h"
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
#include "bootstrap/bootstrap.h"
#include "utils/portal.h" 
#include "access/xact.h"
#include "parser/scansup.h"

#include "bootstrap_tokens.h"

/* 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); }
"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}		{
		    yylval.ival = EnterString(scanstr((char*)yytext));
		    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);
		}



%%

yywrap()
{
    return 1;
}

yyerror(str)
    char *str;
{
    fprintf(stderr,"\tsyntax error %d : %s",yyline, str);
}