LCOV - differential code coverage report
Current view: top level - src/backend/bootstrap - bootscanner.l (source / functions) Coverage Total Hit UNC LBC UIC UBC GBC GIC GNC CBC EUB ECB DCB
Current: Differential Code Coverage HEAD vs 15 Lines: 82.0 % 50 41 2 1 5 1 1 2 20 18 7 5 17
Current Date: 2023-04-08 15:15:32 Functions: 0.0 % 2 0 1 1 2
Baseline: 15
Baseline Date: 2023-04-08 15:09:40
Legend: Lines: hit not hit

           TLA  Line data    Source code
       1                 : %top{
       2                 : /*-------------------------------------------------------------------------
       3                 :  *
       4                 :  * bootscanner.l
       5                 :  *    a lexical scanner for the bootstrap parser
       6                 :  *
       7                 :  * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
       8                 :  * Portions Copyright (c) 1994, Regents of the University of California
       9                 :  *
      10                 :  *
      11                 :  * IDENTIFICATION
      12                 :  *    src/backend/bootstrap/bootscanner.l
      13                 :  *
      14                 :  *-------------------------------------------------------------------------
      15                 :  */
      16                 : #include "postgres.h"
      17                 : 
      18                 : /*
      19                 :  * NB: include bootparse.h only AFTER including bootstrap.h, because bootstrap.h
      20                 :  * includes node definitions needed for YYSTYPE.
      21                 :  */
      22                 : #include "bootstrap/bootstrap.h"
      23                 : #include "bootparse.h"
      24                 : #include "utils/guc.h"
      25                 : 
      26                 : }
      27                 : 
      28                 : %{
      29                 : 
      30                 : /* LCOV_EXCL_START */
      31                 : 
      32                 : /* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */
      33                 : #undef fprintf
      34                 : #define fprintf(file, fmt, msg)  fprintf_to_ereport(fmt, msg)
      35                 : 
      36                 : static void
      37 UIC           0 : fprintf_to_ereport(const char *fmt, const char *msg)
      38                 : {
      39               0 :     ereport(ERROR, (errmsg_internal("%s", msg)));
      40                 : }
      41                 : 
      42                 : 
      43 EUB             : static int  yyline = 1;         /* line number for error reporting */
      44                 : 
      45                 : %}
      46                 : 
      47                 : %option 8bit
      48                 : %option never-interactive
      49                 : %option nodefault
      50                 : %option noinput
      51                 : %option nounput
      52                 : %option noyywrap
      53                 : %option warn
      54                 : %option prefix="boot_yy"
      55                 : 
      56                 : 
      57                 : id      [-A-Za-z0-9_]+
      58                 : sid     \'([^']|\'\')*\'
      59                 : 
      60                 : /*
      61                 :  * Keyword tokens return the keyword text (as a constant string) in boot_yylval.kw,
      62                 :  * just in case that's needed because we want to treat the keyword as an
      63                 :  * unreserved identifier.  Note that _null_ is not treated as a keyword
      64                 :  * for this purpose; it's the one "reserved word" in the bootstrap syntax.
      65                 :  *
      66                 :  * Notice that all the keywords are case-sensitive, and for historical
      67                 :  * reasons some must be upper case.
      68                 :  *
      69                 :  * String tokens return a palloc'd string in boot_yylval.str.
      70                 :  */
      71                 : 
      72                 : %%
      73                 : 
      74 GNC       18300 : open            { boot_yylval.kw = "open"; return OPEN; }
      75                 : 
      76           19520 : close           { boot_yylval.kw = "close"; return XCLOSE; }
      77 GIC       19520 : 
      78 GNC       19520 : create          { boot_yylval.kw = "create"; return XCREATE; }
      79 GIC       19520 : 
      80 UNC           0 : OID             { boot_yylval.kw = "OID"; return OBJ_ID; }
      81 GNC        1220 : bootstrap       { boot_yylval.kw = "bootstrap"; return XBOOTSTRAP; }
      82            3355 : shared_relation { boot_yylval.kw = "shared_relation"; return XSHARED_RELATION; }
      83            3965 : rowtype_oid     { boot_yylval.kw = "rowtype_oid"; return XROWTYPE_OID; }
      84 CBC        3355 : 
      85 GNC     3218360 : insert          { boot_yylval.kw = "insert"; return INSERT_TUPLE; }
      86 GBC     3215615 : 
      87 CBC     9345813 : _null_          { return NULLVAL; }
      88         9345813 : 
      89          187270 : ","               { return COMMA; }
      90          369355 : "="               { return EQUALS; }
      91         3272955 : "("               { return LPAREN; }
      92         3455040 : ")"               { return RPAREN; }
      93         3272955 : 
      94         3272955 : [\n]            { yyline++; }
      95         3543490 : [\r\t ]         ;
      96        58971445 : 
      97        55427955 : ^\#[^\n]*       ;       /* drop everything after "#" for comments */
      98             305 : 
      99 GNC       48800 : declare         { boot_yylval.kw = "declare"; return XDECLARE; }
     100           49105 : build           { boot_yylval.kw = "build"; return XBUILD; }
     101             305 : indices         { boot_yylval.kw = "indices"; return INDICES; }
     102           33855 : unique          { boot_yylval.kw = "unique"; return UNIQUE; }
     103           38125 : index           { boot_yylval.kw = "index"; return INDEX; }
     104           82350 : on              { boot_yylval.kw = "on"; return ON; }
     105           75640 : using           { boot_yylval.kw = "using"; return USING; }
     106           59780 : toast           { boot_yylval.kw = "toast"; return XTOAST; }
     107           48800 : FORCE           { boot_yylval.kw = "FORCE"; return XFORCE; }
     108           21350 : NOT             { boot_yylval.kw = "NOT"; return XNOT; }
     109           21960 : NULL            { boot_yylval.kw = "NULL"; return XNULL; }
     110 CBC       10370 : 
     111           10980 : {id}            {
     112 GNC    36926655 :                     boot_yylval.str = pstrdup(yytext);
     113 CBC    36926655 :                     return ID;
     114 ECB             :                 }
     115                 : {sid}           {
     116 CBC     2169462 :                     /* strip quotes and escapes */
     117 GNC     2169462 :                     boot_yylval.str = DeescapeQuotedString(yytext);
     118 CBC     4338924 :                     return ID;
     119 ECB             :                 }
     120                 : 
     121 UIC           0 : .               {
     122 LBC           0 :                     elog(ERROR, "syntax error at line %d: unexpected character \"%s\"", yyline, yytext);
     123 ECB             :                 }
     124                 : 
     125 UIC           0 : %%
     126               0 : 
     127 EUB             : /* LCOV_EXCL_STOP */
     128                 : 
     129                 : void
     130 UNC           0 : boot_yyerror(const char *message)
     131 EUB             : {
     132 UBC           0 :     elog(ERROR, "%s at line %d", message, yyline);
     133                 : }
        

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