LCOV - differential code coverage report
Current view: top level - contrib/cube - cubescan.l (source / functions) Coverage Total Hit LBC UIC GIC GNC CBC EUB ECB DUB DCB
Current: Differential Code Coverage HEAD vs 15 Lines: 91.2 % 34 31 1 2 9 14 8 2 20 1 2
Current Date: 2023-04-08 15:15:32 Functions: 75.0 % 4 3 1 1 2 1 3
Baseline: 15
Baseline Date: 2023-04-08 15:09:40
Legend: Lines: hit not hit

           TLA  Line data    Source code
       1                 : %top{
       2                 : /*
       3                 :  * A scanner for EMP-style numeric ranges
       4                 :  * contrib/cube/cubescan.l
       5                 :  */
       6                 : 
       7                 : #include "postgres.h"
       8                 : 
       9                 : /*
      10                 :  * NB: include cubeparse.h only AFTER defining YYSTYPE (to match cubeparse.y)
      11                 :  * and cubedata.h for NDBOX.
      12                 :  */
      13                 : #include "cubedata.h"
      14                 : #define YYSTYPE char *
      15                 : #include "cubeparse.h"
      16                 : }
      17                 : 
      18                 : %{
      19                 : /* LCOV_EXCL_START */
      20                 : 
      21                 : /* No reason to constrain amount of data slurped */
      22                 : #define YY_READ_BUF_SIZE 16777216
      23                 : 
      24                 : /* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */
      25                 : #undef fprintf
      26                 : #define fprintf(file, fmt, msg)  fprintf_to_ereport(fmt, msg)
      27                 : 
      28                 : static void
      29 UIC           0 : fprintf_to_ereport(const char *fmt, const char *msg)
      30                 : {
      31               0 :     ereport(ERROR, (errmsg_internal("%s", msg)));
      32                 : }
      33                 : 
      34                 : /* Handles to the buffer that the lexer uses internally */
      35                 : static YY_BUFFER_STATE scanbufhandle;
      36                 : static char *scanbuf;
      37                 : %}
      38                 : 
      39 EUB             : %option 8bit
      40                 : %option never-interactive
      41                 : %option nodefault
      42                 : %option noinput
      43                 : %option nounput
      44                 : %option noyywrap
      45                 : %option warn
      46                 : %option prefix="cube_yy"
      47                 : 
      48                 : 
      49                 : n            [0-9]+
      50                 : integer      [+-]?{n}
      51                 : real         [+-]?({n}\.{n}?|\.{n})
      52                 : float        ({integer}|{real})([eE]{integer})?
      53                 : infinity     [+-]?[iI][nN][fF]([iI][nN][iI][tT][yY])?
      54                 : NaN          [nN][aA][nN]
      55                 : 
      56                 : %%
      57                 : 
      58 GNC       14058 : {float}      cube_yylval = yytext; return CUBEFLOAT;
      59               2 : {infinity}   cube_yylval = yytext; return CUBEFLOAT;
      60               2 : {NaN}        cube_yylval = yytext; return CUBEFLOAT;
      61               1 : \[           cube_yylval = "("; return O_BRACKET;
      62              23 : \]           cube_yylval = ")"; return C_BRACKET;
      63              21 : \(           cube_yylval = "("; return O_PAREN;
      64            6604 : \)           cube_yylval = ")"; return C_PAREN;
      65            6602 : \,           cube_yylval = ","; return COMMA;
      66 GIC       10645 : [ \t\n\r\f]+ /* discard spaces */
      67              39 : .            return yytext[0]; /* alert parser of the garbage */
      68 CBC           6 : 
      69 LBC           0 : %%
      70 ECB             : 
      71                 : /* LCOV_EXCL_STOP */
      72                 : 
      73                 : /* result and scanbuflen are not used, but Bison expects this signature */
      74                 : void
      75 GNC          24 : cube_yyerror(NDBOX **result, Size scanbuflen,
      76                 :              struct Node *escontext,
      77                 :              const char *message)
      78 ECB             : {
      79 CBC          24 :     if (*yytext == YY_END_OF_BUFFER_CHAR)
      80 ECB             :     {
      81 GNC           3 :         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 ECB             :     else
      88                 :     {
      89 GNC          21 :         errsave(escontext,
      90                 :                 (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
      91 ECB             :                  errmsg("invalid input syntax for cube"),
      92                 :                  /* translator: first %s is typically "syntax error" */
      93                 :                  errdetail("%s at or near \"%s\"", message, yytext)));
      94                 :     }
      95 GIC           1 : }
      96                 : 
      97                 : 
      98                 : /*
      99                 :  * Called before any actual parsing is done
     100                 :  */
     101 ECB             : void
     102 GNC        3435 : cube_scanner_init(const char *str, Size *scanbuflen)
     103                 : {
     104            3435 :     Size        slen = strlen(str);
     105                 : 
     106                 :     /*
     107 ECB             :      * Might be left over after ereport()
     108                 :      */
     109 GIC        3435 :     if (YY_CURRENT_BUFFER)
     110              30 :         yy_delete_buffer(YY_CURRENT_BUFFER);
     111                 : 
     112                 :     /*
     113                 :      * Make a scan buffer with special termination needed by flex.
     114 ECB             :      */
     115 GNC        3435 :     *scanbuflen = slen;
     116 CBC        3435 :     scanbuf = palloc(slen + 2);
     117 GIC        3435 :     memcpy(scanbuf, str, slen);
     118            3435 :     scanbuf[slen] = scanbuf[slen + 1] = YY_END_OF_BUFFER_CHAR;
     119            3435 :     scanbufhandle = yy_scan_buffer(scanbuf, slen + 2);
     120                 : 
     121 CBC        3435 :     BEGIN(INITIAL);
     122            3435 : }
     123                 : 
     124                 : 
     125                 : /*
     126                 :  * Called after parsing is done to clean up after cube_scanner_init()
     127 ECB             :  */
     128                 : void
     129 CBC        3405 : cube_scanner_finish(void)
     130 ECB             : {
     131 CBC        3405 :     yy_delete_buffer(scanbufhandle);
     132 GIC        3405 :     pfree(scanbuf);
     133 CBC        3405 : }
        

Generated by: LCOV version v1.16-55-g56c0a2a