LCOV - code coverage report
Current view: top level - src/backend/bootstrap - bootscanner.l (source / functions) Hit Total Coverage
Test: PostgreSQL 15devel Lines: 0 2 0.0 %
Date: 2021-12-05 01:09:12 Functions: 0 1 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : %{
       2             : /*-------------------------------------------------------------------------
       3             :  *
       4             :  * bootscanner.l
       5             :  *    a lexical scanner for the bootstrap parser
       6             :  *
       7             :  * Portions Copyright (c) 1996-2021, 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             : #include "bootstrap/bootstrap.h"
      19             : #include "utils/guc.h"
      20             : 
      21             : /* Not needed now that this file is compiled as part of bootparse. */
      22             : /* #include "bootparse.h" */
      23             : 
      24             : /* LCOV_EXCL_START */
      25             : 
      26             : /* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */
      27             : #undef fprintf
      28             : #define fprintf(file, fmt, msg)  fprintf_to_ereport(fmt, msg)
      29             : 
      30             : static void
      31             : fprintf_to_ereport(const char *fmt, const char *msg)
      32             : {
      33             :     ereport(ERROR, (errmsg_internal("%s", msg)));
      34             : }
      35             : 
      36             : 
      37             : static int  yyline = 1;         /* line number for error reporting */
      38             : 
      39             : %}
      40             : 
      41             : %option 8bit
      42             : %option never-interactive
      43             : %option nodefault
      44             : %option noinput
      45             : %option nounput
      46             : %option noyywrap
      47             : %option warn
      48             : %option prefix="boot_yy"
      49             : 
      50             : 
      51             : id      [-A-Za-z0-9_]+
      52             : sid     \'([^']|\'\')*\'
      53             : 
      54             : /*
      55             :  * Keyword tokens return the keyword text (as a constant string) in yylval.kw,
      56             :  * just in case that's needed because we want to treat the keyword as an
      57             :  * unreserved identifier.  Note that _null_ is not treated as a keyword
      58             :  * for this purpose; it's the one "reserved word" in the bootstrap syntax.
      59             :  *
      60             :  * Notice that all the keywords are case-sensitive, and for historical
      61             :  * reasons some must be upper case.
      62             :  *
      63             :  * String tokens return a palloc'd string in yylval.str.
      64             :  */
      65             : 
      66             : %%
      67             : 
      68             : open            { yylval.kw = "open"; return OPEN; }
      69             : 
      70             : close           { yylval.kw = "close"; return XCLOSE; }
      71             : 
      72             : create          { yylval.kw = "create"; return XCREATE; }
      73             : 
      74             : OID             { yylval.kw = "OID"; return OBJ_ID; }
      75             : bootstrap       { yylval.kw = "bootstrap"; return XBOOTSTRAP; }
      76             : shared_relation { yylval.kw = "shared_relation"; return XSHARED_RELATION; }
      77             : rowtype_oid     { yylval.kw = "rowtype_oid"; return XROWTYPE_OID; }
      78             : 
      79             : insert          { yylval.kw = "insert"; return INSERT_TUPLE; }
      80             : 
      81             : _null_          { return NULLVAL; }
      82             : 
      83             : ","               { return COMMA; }
      84             : "="               { return EQUALS; }
      85             : "("               { return LPAREN; }
      86             : ")"               { return RPAREN; }
      87             : 
      88             : [\n]            { yyline++; }
      89             : [\r\t ]         ;
      90             : 
      91             : ^\#[^\n]*       ;       /* drop everything after "#" for comments */
      92             : 
      93             : declare         { yylval.kw = "declare"; return XDECLARE; }
      94             : build           { yylval.kw = "build"; return XBUILD; }
      95             : indices         { yylval.kw = "indices"; return INDICES; }
      96             : unique          { yylval.kw = "unique"; return UNIQUE; }
      97             : index           { yylval.kw = "index"; return INDEX; }
      98             : on              { yylval.kw = "on"; return ON; }
      99             : using           { yylval.kw = "using"; return USING; }
     100             : toast           { yylval.kw = "toast"; return XTOAST; }
     101             : FORCE           { yylval.kw = "FORCE"; return XFORCE; }
     102             : NOT             { yylval.kw = "NOT"; return XNOT; }
     103             : NULL            { yylval.kw = "NULL"; return XNULL; }
     104             : 
     105             : {id}            {
     106             :                     yylval.str = pstrdup(yytext);
     107             :                     return ID;
     108             :                 }
     109             : {sid}           {
     110             :                     /* strip quotes and escapes */
     111             :                     yylval.str = DeescapeQuotedString(yytext);
     112             :                     return ID;
     113             :                 }
     114             : 
     115             : .               {
     116             :                     elog(ERROR, "syntax error at line %d: unexpected character \"%s\"", yyline, yytext);
     117             :                 }
     118             : 
     119             : %%
     120             : 
     121             : /* LCOV_EXCL_STOP */
     122             : 
     123             : void
     124           0 : yyerror(const char *message)
     125             : {
     126           0 :     elog(ERROR, "%s at line %d", message, yyline);
     127             : }

Generated by: LCOV version 1.14