PostgreSQL Source Code git master
segscan.l File Reference
#include "postgres.h"
#include "nodes/miscnodes.h"
#include "segdata.h"
#include "segparse.h"
Include dependency graph for segscan.l:

Go to the source code of this file.

Macros

#define YY_READ_BUF_SIZE   16777216
 
#define fprintf(file, fmt, msg)   fprintf_to_ereport(fmt, msg)
 

Functions

static void fprintf_to_ereport (const char *fmt, const char *msg)
 
int yylex (YYSTYPE *yylval_param, yyscan_t yyscanner)
 
void seg_yyerror (SEG *result, struct Node *escontext, yyscan_t yyscanner, const char *message)
 
void seg_scanner_init (const char *str, yyscan_t *yyscannerp)
 
void seg_scanner_finish (yyscan_t yyscanner)
 
void * yyalloc (yy_size_t size, yyscan_t yyscanner)
 
void * yyrealloc (void *ptr, yy_size_t size, yyscan_t yyscanner)
 
void yyfree (void *ptr, yyscan_t yyscanner)
 

Macro Definition Documentation

◆ fprintf

#define fprintf (   file,
  fmt,
  msg 
)    fprintf_to_ereport(fmt, msg)

Definition at line 21 of file segscan.l.

◆ YY_READ_BUF_SIZE

#define YY_READ_BUF_SIZE   16777216

Definition at line 17 of file segscan.l.

Function Documentation

◆ fprintf_to_ereport()

static void fprintf_to_ereport ( const char *  fmt,
const char *  msg 
)
static

Definition at line 24 of file segscan.l.

25{
26 ereport(ERROR, (errmsg_internal("%s", msg)));
int errmsg_internal(const char *fmt,...)
Definition: elog.c:1157
#define ERROR
Definition: elog.h:39
#define ereport(elevel,...)
Definition: elog.h:149
27}

References ereport, errmsg_internal(), and ERROR.

◆ seg_scanner_finish()

void seg_scanner_finish ( yyscan_t  yyscanner)

Definition at line 116 of file segscan.l.

117{
118 yylex_destroy(yyscanner);
119}

Referenced by seg_in().

◆ seg_scanner_init()

void seg_scanner_init ( const char *  str,
yyscan_t yyscannerp 
)

Definition at line 99 of file segscan.l.

100{
101 yyscan_t yyscanner;
void * yyscan_t
Definition: cubedata.h:67
102
103 if (yylex_init(yyscannerp) != 0)
104 elog(ERROR, "yylex_init() failed: %m");
#define elog(elevel,...)
Definition: elog.h:225
105
106 yyscanner = *yyscannerp;
107
108 yy_scan_string(str, yyscanner);
const char * str
109}

References elog, ERROR, and str.

Referenced by seg_in().

◆ seg_yyerror()

void seg_yyerror ( SEG result,
struct Node escontext,
yyscan_t  yyscanner,
const char *  message 
)

Definition at line 67 of file segscan.l.

68{
69 struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; /* needed for yytext
70 * macro */
71
72 /* if we already reported an error, don't overwrite it */
73 if (SOFT_ERROR_OCCURRED(escontext))
74 return;
#define SOFT_ERROR_OCCURRED(escontext)
Definition: miscnodes.h:53
75
76 if (*yytext == YY_END_OF_BUFFER_CHAR)
77 {
78 errsave(escontext,
79 (errcode(ERRCODE_SYNTAX_ERROR),
80 errmsg("bad seg representation"),
81 /* translator: %s is typically "syntax error" */
82 errdetail("%s at end of input", message)));
83 }
84 else
85 {
86 errsave(escontext,
87 (errcode(ERRCODE_SYNTAX_ERROR),
88 errmsg("bad seg representation"),
89 /* translator: first %s is typically "syntax error" */
90 errdetail("%s at or near \"%s\"", message, yytext)));
91 }
int errdetail(const char *fmt,...)
Definition: elog.c:1203
int errcode(int sqlerrcode)
Definition: elog.c:853
int errmsg(const char *fmt,...)
Definition: elog.c:1070
#define errsave(context,...)
Definition: elog.h:261
92}

References errcode(), errdetail(), errmsg(), errsave, and SOFT_ERROR_OCCURRED.

Referenced by seg_in().

◆ yyalloc()

void * yyalloc ( yy_size_t  size,
yyscan_t  yyscanner 
)

Definition at line 127 of file segscan.l.

128{
129 return palloc(size);
void * palloc(Size size)
Definition: mcxt.c:1317
static pg_noinline void Size size
Definition: slab.c:607
130}

References palloc(), and size.

◆ yyfree()

void yyfree ( void *  ptr,
yyscan_t  yyscanner 
)

Definition at line 142 of file segscan.l.

143{
144 if (ptr)
145 pfree(ptr);
void pfree(void *pointer)
Definition: mcxt.c:1521
146}

References pfree().

◆ yylex()

int yylex ( YYSTYPE yylval_param,
yyscan_t  yyscanner 
)

Definition at line 51 of file segscan.l.

53{range} yylval->text = yytext; return RANGE;
54{plumin} yylval->text = yytext; return PLUMIN;
55{float} yylval->text = yytext; return SEGFLOAT;
56\< yylval->text = "<"; return EXTENSION;
57\> yylval->text = ">"; return EXTENSION;
58\~ yylval->text = "~"; return EXTENSION;
59[ \t\n\r\f\v]+ /* discard spaces */
60. return yytext[0]; /* alert parser of the garbage */
61
62%%

◆ yyrealloc()

void * yyrealloc ( void *  ptr,
yy_size_t  size,
yyscan_t  yyscanner 
)

Definition at line 133 of file segscan.l.

134{
135 if (ptr)
136 return repalloc(ptr, size);
137 else
138 return palloc(size);
void * repalloc(void *pointer, Size size)
Definition: mcxt.c:1541
139}

References palloc(), repalloc(), and size.