2000-12-12 04:39:15 +08:00
|
|
|
%{
|
|
|
|
/*
|
|
|
|
** A scanner for EMP-style numeric ranges
|
|
|
|
*/
|
|
|
|
|
2002-09-05 08:43:07 +08:00
|
|
|
#include "postgres.h"
|
|
|
|
|
2000-12-12 04:39:15 +08:00
|
|
|
#include "buffer.h"
|
|
|
|
|
2003-05-30 06:30:02 +08:00
|
|
|
/* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */
|
|
|
|
#define fprintf(file, fmt, msg) ereport(ERROR, (errmsg_internal("%s", msg)))
|
|
|
|
|
2000-12-12 04:39:15 +08:00
|
|
|
|
2002-11-07 14:06:17 +08:00
|
|
|
/* flex screws a couple symbols when used with the -P option; fix those */
|
2000-12-12 04:39:15 +08:00
|
|
|
#define YY_DECL int cube_yylex YY_PROTO(( void )); \
|
|
|
|
int cube_yylex YY_PROTO(( void ))
|
2002-11-07 14:06:17 +08:00
|
|
|
#define yylval cube_yylval
|
|
|
|
|
2000-12-12 04:39:15 +08:00
|
|
|
|
|
|
|
/* redefined YY_INPUT reads byte-wise from the memory area defined in buffer.c */
|
|
|
|
#undef YY_INPUT
|
|
|
|
#define YY_INPUT(buf,result,max_size) \
|
|
|
|
{ \
|
|
|
|
int c = read_parse_buffer(); \
|
|
|
|
result = (c == '\0') ? YY_NULL : (buf[0] = c, 1); \
|
|
|
|
}
|
|
|
|
|
|
|
|
void cube_flush_scanner_buffer(void);
|
|
|
|
%}
|
|
|
|
|
2002-07-31 00:33:08 +08:00
|
|
|
%option 8bit
|
|
|
|
%option never-interactive
|
|
|
|
%option nounput
|
|
|
|
%option noyywrap
|
|
|
|
|
|
|
|
|
2000-12-12 04:39:15 +08:00
|
|
|
n [0-9]+
|
|
|
|
integer [+-]?{n}
|
2002-08-30 07:03:58 +08:00
|
|
|
real [+-]?({n}\.{n}?|\.{n})
|
2000-12-12 04:39:15 +08:00
|
|
|
float ({integer}|{real})([eE]{integer})?
|
|
|
|
|
|
|
|
%%
|
|
|
|
|
|
|
|
{float} yylval = yytext; return FLOAT;
|
|
|
|
\[ yylval = "("; return O_BRACKET;
|
|
|
|
\] yylval = ")"; return C_BRACKET;
|
|
|
|
\( yylval = "("; return O_PAREN;
|
|
|
|
\) yylval = ")"; return C_PAREN;
|
|
|
|
\, yylval = ")"; return COMMA;
|
|
|
|
[ ]+ /* discard spaces */
|
|
|
|
. return yytext[0]; /* alert parser of the garbage */
|
|
|
|
|
|
|
|
%%
|
|
|
|
|
|
|
|
int cube_yylex();
|
|
|
|
|
|
|
|
void cube_flush_scanner_buffer(void) {
|
|
|
|
YY_FLUSH_BUFFER;
|
|
|
|
}
|