diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2000-12-11 20:40:33 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2000-12-11 20:40:33 +0000 |
commit | a3694b420f194ba26f3bf721f4a53fc0a43c2581 (patch) | |
tree | c7381cad0c118f47d04f3b2a986f3ca95b0dc038 /contrib/seg/segscan.l | |
parent | 9892ddf5ee0c1c82e879f4bb20bf1f53b4241a45 (diff) | |
download | postgresql-a3694b420f194ba26f3bf721f4a53fc0a43c2581.tar.gz |
Gene Selkov's SEG datatype (GiST example code)
Diffstat (limited to 'contrib/seg/segscan.l')
-rw-r--r-- | contrib/seg/segscan.l | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/contrib/seg/segscan.l b/contrib/seg/segscan.l new file mode 100644 index 0000000000..ea9032685a --- /dev/null +++ b/contrib/seg/segscan.l @@ -0,0 +1,53 @@ +%{ +/* +** A scanner for EMP-style numeric ranges +*/ + +#include <string.h> +#include <stdio.h> +#include "segparse.h" +#include "buffer.h" + +#define YY_NO_UNPUT 1 +#undef yywrap + +/* flex screws a couple symbols when used with the -P otion; fix those */ +#define YY_DECL int seg_yylex YY_PROTO(( void )); \ +int seg_yylex YY_PROTO(( void )) +#define yylval seg_yylval + +/* 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 seg_flush_scanner_buffer(void); +%} + +range (\.\.)(\.)? +plumin (\'\+\-\')|(\(\+\-)\) +integer [+-]?[0-9]+ +real [+-]?[0-9]+\.[0-9]+ +float ({integer}|{real})([eE]{integer})? + +%% + +{range} yylval.text = yytext; return RANGE; +{plumin} yylval.text = yytext; return PLUMIN; +{float} yylval.text = yytext; return FLOAT; +\< yylval.text = "<"; return EXTENSION; +\> yylval.text = ">"; return EXTENSION; +\~ yylval.text = "~"; return EXTENSION; +[ ]+ /* discard spaces */ +. return yytext[0]; /* alert parser of the garbage */ + +%% + +int seg_yylex(); + +void seg_flush_scanner_buffer(void) { + YY_FLUSH_BUFFER; +} |