LCOV - code coverage report
Current view: top level - src/backend/bootstrap - bootscanner.l (source / functions) Hit Total Coverage
Test: PostgreSQL 13devel Lines: 0 2 0.0 %
Date: 2019-11-15 22:06:47 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-2019, 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 "access/attnum.h"
      19             : #include "access/htup.h"
      20             : #include "access/itup.h"
      21             : #include "access/tupdesc.h"
      22             : #include "bootstrap/bootstrap.h"
      23             : #include "catalog/pg_am.h"
      24             : #include "catalog/pg_attribute.h"
      25             : #include "catalog/pg_class.h"
      26             : #include "nodes/nodes.h"
      27             : #include "nodes/parsenodes.h"
      28             : #include "nodes/pg_list.h"
      29             : #include "nodes/primnodes.h"
      30             : #include "parser/scansup.h"
      31             : #include "rewrite/prs2lock.h"
      32             : #include "storage/block.h"
      33             : #include "storage/fd.h"
      34             : #include "storage/itemptr.h"
      35             : #include "storage/off.h"
      36             : #include "utils/rel.h"
      37             : 
      38             : /* Not needed now that this file is compiled as part of bootparse. */
      39             : /* #include "bootparse.h" */
      40             : 
      41             : /* LCOV_EXCL_START */
      42             : 
      43             : /* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */
      44             : #undef fprintf
      45             : #define fprintf(file, fmt, msg)  fprintf_to_ereport(fmt, msg)
      46             : 
      47             : static void
      48             : fprintf_to_ereport(const char *fmt, const char *msg)
      49             : {
      50             :     ereport(ERROR, (errmsg_internal("%s", msg)));
      51             : }
      52             : 
      53             : 
      54             : static int  yyline = 1;         /* line number for error reporting */
      55             : 
      56             : %}
      57             : 
      58             : %option 8bit
      59             : %option never-interactive
      60             : %option nodefault
      61             : %option noinput
      62             : %option nounput
      63             : %option noyywrap
      64             : %option warn
      65             : %option prefix="boot_yy"
      66             : 
      67             : 
      68             : id      [-A-Za-z0-9_]+
      69             : sid     \"([^\"])*\"
      70             : 
      71             : /*
      72             :  * Keyword tokens return the keyword text (as a constant string) in yylval.kw,
      73             :  * just in case that's needed because we want to treat the keyword as an
      74             :  * unreserved identifier.  Note that _null_ is not treated as a keyword
      75             :  * for this purpose; it's the one "reserved word" in the bootstrap syntax.
      76             :  *
      77             :  * Notice that all the keywords are case-sensitive, and for historical
      78             :  * reasons some must be upper case.
      79             :  *
      80             :  * String tokens return a palloc'd string in yylval.str.
      81             :  */
      82             : 
      83             : %%
      84             : 
      85             : open            { yylval.kw = "open"; return OPEN; }
      86             : 
      87             : close           { yylval.kw = "close"; return XCLOSE; }
      88             : 
      89             : create          { yylval.kw = "create"; return XCREATE; }
      90             : 
      91             : OID             { yylval.kw = "OID"; return OBJ_ID; }
      92             : bootstrap       { yylval.kw = "bootstrap"; return XBOOTSTRAP; }
      93             : shared_relation { yylval.kw = "shared_relation"; return XSHARED_RELATION; }
      94             : rowtype_oid     { yylval.kw = "rowtype_oid"; return XROWTYPE_OID; }
      95             : 
      96             : insert          { yylval.kw = "insert"; return INSERT_TUPLE; }
      97             : 
      98             : _null_          { return NULLVAL; }
      99             : 
     100             : ","               { return COMMA; }
     101             : "="               { return EQUALS; }
     102             : "("               { return LPAREN; }
     103             : ")"               { return RPAREN; }
     104             : 
     105             : [\n]            { yyline++; }
     106             : [\r\t ]         ;
     107             : 
     108             : ^\#[^\n]*       ;       /* drop everything after "#" for comments */
     109             : 
     110             : declare         { yylval.kw = "declare"; return XDECLARE; }
     111             : build           { yylval.kw = "build"; return XBUILD; }
     112             : indices         { yylval.kw = "indices"; return INDICES; }
     113             : unique          { yylval.kw = "unique"; return UNIQUE; }
     114             : index           { yylval.kw = "index"; return INDEX; }
     115             : on              { yylval.kw = "on"; return ON; }
     116             : using           { yylval.kw = "using"; return USING; }
     117             : toast           { yylval.kw = "toast"; return XTOAST; }
     118             : FORCE           { yylval.kw = "FORCE"; return XFORCE; }
     119             : NOT             { yylval.kw = "NOT"; return XNOT; }
     120             : NULL            { yylval.kw = "NULL"; return XNULL; }
     121             : 
     122             : {id}            {
     123             :                     yylval.str = scanstr(yytext);
     124             :                     return ID;
     125             :                 }
     126             : {sid}           {
     127             :                     /* leading and trailing quotes are not passed to scanstr */
     128             :                     yytext[strlen(yytext) - 1] = '\0';
     129             :                     yylval.str = scanstr(yytext+1);
     130             :                     yytext[strlen(yytext)] = '"';  /* restore yytext */
     131             :                     return ID;
     132             :                 }
     133             : 
     134             : .               {
     135             :                     elog(ERROR, "syntax error at line %d: unexpected character \"%s\"", yyline, yytext);
     136             :                 }
     137             : 
     138             : %%
     139             : 
     140             : /* LCOV_EXCL_STOP */
     141             : 
     142             : void
     143             : yyerror(const char *message)
     144           0 : {
     145             :     elog(ERROR, "%s at line %d", message, yyline);
     146           0 : }

Generated by: LCOV version 1.13