PostgreSQL Source Code git master
cubescan.l File Reference
#include "postgres.h"
#include "cubedata.h"
#include "cubeparse.h"
Include dependency graph for cubescan.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 cube_yyerror (NDBOX **result, Size scanbuflen, struct Node *escontext, yyscan_t yyscanner, const char *message)
 
void cube_scanner_init (const char *str, Size *scanbuflen, yyscan_t *yyscannerp)
 
void cube_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 cubescan.l.

◆ YY_READ_BUF_SIZE

#define YY_READ_BUF_SIZE   16777216

Definition at line 17 of file cubescan.l.

Function Documentation

◆ cube_scanner_finish()

void cube_scanner_finish ( yyscan_t  yyscanner)

Definition at line 121 of file cubescan.l.

122{
123 yylex_destroy(yyscanner);
124}

Referenced by cube_in().

◆ cube_scanner_init()

void cube_scanner_init ( const char *  str,
Size scanbuflen,
yyscan_t yyscannerp 
)

Definition at line 102 of file cubescan.l.

103{
104 Size slen = strlen(str);
105 yyscan_t yyscanner;
size_t Size
Definition: c.h:562
void * yyscan_t
Definition: cubedata.h:67
const char * str
106
107 if (yylex_init(yyscannerp) != 0)
108 elog(ERROR, "yylex_init() failed: %m");
#define ERROR
Definition: elog.h:39
#define elog(elevel,...)
Definition: elog.h:225
109
110 yyscanner = *yyscannerp;
111
112 yy_scan_bytes(str, slen, yyscanner);
113 *scanbuflen = slen;
114}

References elog, ERROR, and str.

Referenced by cube_in().

◆ cube_yyerror()

void cube_yyerror ( NDBOX **  result,
Size  scanbuflen,
struct Node escontext,
yyscan_t  yyscanner,
const char *  message 
)

Definition at line 71 of file cubescan.l.

75{
76 struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; /* needed for yytext
77 * macro */
78
79 if (*yytext == YY_END_OF_BUFFER_CHAR)
80 {
81 errsave(escontext,
82 (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
83 errmsg("invalid input syntax for cube"),
84 /* translator: %s is typically "syntax error" */
85 errdetail("%s at end of input", message)));
86 }
87 else
88 {
89 errsave(escontext,
90 (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
91 errmsg("invalid input syntax for cube"),
92 /* translator: first %s is typically "syntax error" */
93 errdetail("%s at or near \"%s\"", message, yytext)));
94 }
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
95}

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

◆ fprintf_to_ereport()

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

Definition at line 24 of file cubescan.l.

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

References ereport, errmsg_internal(), and ERROR.

◆ yyalloc()

void * yyalloc ( yy_size_t  size,
yyscan_t  yyscanner 
)

Definition at line 132 of file cubescan.l.

133{
134 return palloc(size);
void * palloc(Size size)
Definition: mcxt.c:1317
static pg_noinline void Size size
Definition: slab.c:607
135}

References palloc(), and size.

◆ yyfree()

void yyfree ( void *  ptr,
yyscan_t  yyscanner 
)

Definition at line 147 of file cubescan.l.

148{
149 if (ptr)
150 pfree(ptr);
void pfree(void *pointer)
Definition: mcxt.c:1521
151}

References pfree().

◆ yylex()

int yylex ( YYSTYPE yylval_param,
yyscan_t  yyscanner 
)

Definition at line 52 of file cubescan.l.

54{float} *yylval = yytext; return CUBEFLOAT;
55{infinity} *yylval = yytext; return CUBEFLOAT;
56{NaN} *yylval = yytext; return CUBEFLOAT;
57\[ *yylval = "("; return O_BRACKET;
58\] *yylval = ")"; return C_BRACKET;
59\( *yylval = "("; return O_PAREN;
60\) *yylval = ")"; return C_PAREN;
61\, *yylval = ","; return COMMA;
62[ \t\n\r\f\v]+ /* discard spaces */
63. return yytext[0]; /* alert parser of the garbage */
64
65%%

◆ yyrealloc()

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

Definition at line 138 of file cubescan.l.

139{
140 if (ptr)
141 return repalloc(ptr, size);
142 else
143 return palloc(size);
void * repalloc(void *pointer, Size size)
Definition: mcxt.c:1541
144}

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