LCOV - code coverage report
Current view: top level - src/backend/bootstrap - bootscanner.l (source / functions) Hit Total Coverage
Test: PostgreSQL 17devel Lines: 0 2 0.0 %
Date: 2024-04-25 19:11:21 Functions: 0 1 0.0 %
Legend: Lines: hit not hit

          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-2024, 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             : fprintf_to_ereport(const char *fmt, const char *msg)
      38             : {
      39             :     ereport(ERROR, (errmsg_internal("%s", msg)));
      40             : }
      41             : 
      42             : 
      43             : 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             : open            { boot_yylval.kw = "open"; return OPEN; }
      75             : 
      76             : close           { boot_yylval.kw = "close"; return XCLOSE; }
      77             : 
      78             : create          { boot_yylval.kw = "create"; return XCREATE; }
      79             : 
      80             : OID             { boot_yylval.kw = "OID"; return OBJ_ID; }
      81             : bootstrap       { boot_yylval.kw = "bootstrap"; return XBOOTSTRAP; }
      82             : shared_relation { boot_yylval.kw = "shared_relation"; return XSHARED_RELATION; }
      83             : rowtype_oid     { boot_yylval.kw = "rowtype_oid"; return XROWTYPE_OID; }
      84             : 
      85             : insert          { boot_yylval.kw = "insert"; return INSERT_TUPLE; }
      86             : 
      87             : _null_          { return NULLVAL; }
      88             : 
      89             : ","               { return COMMA; }
      90             : "="               { return EQUALS; }
      91             : "("               { return LPAREN; }
      92             : ")"               { return RPAREN; }
      93             : 
      94             : [\n]            { yyline++; }
      95             : [\r\t ]         ;
      96             : 
      97             : ^\#[^\n]*       ;       /* drop everything after "#" for comments */
      98             : 
      99             : declare         { boot_yylval.kw = "declare"; return XDECLARE; }
     100             : build           { boot_yylval.kw = "build"; return XBUILD; }
     101             : indices         { boot_yylval.kw = "indices"; return INDICES; }
     102             : unique          { boot_yylval.kw = "unique"; return UNIQUE; }
     103             : index           { boot_yylval.kw = "index"; return INDEX; }
     104             : on              { boot_yylval.kw = "on"; return ON; }
     105             : using           { boot_yylval.kw = "using"; return USING; }
     106             : toast           { boot_yylval.kw = "toast"; return XTOAST; }
     107             : FORCE           { boot_yylval.kw = "FORCE"; return XFORCE; }
     108             : NOT             { boot_yylval.kw = "NOT"; return XNOT; }
     109             : NULL            { boot_yylval.kw = "NULL"; return XNULL; }
     110             : 
     111             : {id}            {
     112             :                     boot_yylval.str = pstrdup(yytext);
     113             :                     return ID;
     114             :                 }
     115             : {sid}           {
     116             :                     /* strip quotes and escapes */
     117             :                     boot_yylval.str = DeescapeQuotedString(yytext);
     118             :                     return ID;
     119             :                 }
     120             : 
     121             : .               {
     122             :                     elog(ERROR, "syntax error at line %d: unexpected character \"%s\"", yyline, yytext);
     123             :                 }
     124             : 
     125             : %%
     126             : 
     127             : /* LCOV_EXCL_STOP */
     128             : 
     129             : void
     130           0 : boot_yyerror(const char *message)
     131             : {
     132           0 :     elog(ERROR, "%s at line %d", message, yyline);
     133             : }

Generated by: LCOV version 1.14