LCOV - code coverage report
Current view: top level - src/backend/bootstrap - bootscanner.l (source / functions) Hit Total Coverage
Test: PostgreSQL Lines: 46 54 85.2 %
Date: 2017-09-29 13:40:31 Functions: 0 2 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-2017, 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             : 
      42             : /* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */
      43             : #undef fprintf
      44             : #define fprintf(file, fmt, msg)  fprintf_to_ereport(fmt, msg)
      45             : 
      46             : static void
      47           0 : fprintf_to_ereport(const char *fmt, const char *msg)
      48             : {
      49           0 :     ereport(ERROR, (errmsg_internal("%s", msg)));
      50             : }
      51             : 
      52             : 
      53             : static int  yyline = 1;         /* line number for error reporting */
      54             : 
      55             : %}
      56             : 
      57             : %option 8bit
      58             : %option never-interactive
      59             : %option nodefault
      60             : %option noinput
      61             : %option nounput
      62             : %option noyywrap
      63             : %option warn
      64             : %option prefix="boot_yy"
      65             : 
      66             : 
      67             : D       [0-9]
      68             : oct     \\{D}{D}{D}
      69             : id      ([A-Za-z0-9_]|{oct}|\-)+
      70             : sid     \"([^\"])*\"
      71             : arrayid [A-Za-z0-9_]+\[{D}*\]
      72             : 
      73             : %%
      74             : 
      75          58 : open            { return(OPEN); }
      76             : 
      77          62 : close           { return(XCLOSE); }
      78          62 : 
      79          62 : create          { return(XCREATE); }
      80          62 : 
      81        3928 : OID             { return(OBJ_ID); }
      82        3932 : bootstrap       { return(XBOOTSTRAP); }
      83          11 : "shared_relation" { return(XSHARED_RELATION); }
      84          27 : "without_oids"    { return(XWITHOUT_OIDS); }
      85          20 : "rowtype_oid" { return(XROWTYPE_OID); }
      86       23473 : _null_          { return(NULLVAL); }
      87           9 : 
      88       29188 : insert          { return(INSERT_TUPLE); }
      89        5738 : 
      90         528 : ","               { return(COMMA); }
      91        4971 : "="               { return(EQUALS); }
      92        5915 : "("               { return(LPAREN); }
      93       10358 : ")"               { return(RPAREN); }
      94        5915 : 
      95       12603 : [\n]            { yyline++; }
      96        6688 : [\t]            ;
      97        6688 : " "               ;
      98      141494 : 
      99      141494 : ^\#[^\n]* ; /* drop everything after "#" for comments */
     100           1 : 
     101             : 
     102         127 : "declare"     { return(XDECLARE); }
     103           1 : "build"           { return(XBUILD); }
     104           1 : "indices"     { return(INDICES); }
     105         104 : "unique"      { return(UNIQUE); }
     106         116 : "index"           { return(INDEX); }
     107         230 : "on"          { return(ON); }
     108         230 : "using"           { return(USING); }
     109         139 : "toast"           { return(XTOAST); }
     110         133 : "FORCE"           { return(XFORCE); }
     111          30 : "NOT"         { return(XNOT); }
     112          36 : "NULL"            { return(XNULL); }
     113          18 : 
     114          18 : {arrayid}       {
     115          45 :                     yylval.str = MapArrayTypeName(yytext);
     116          45 :                     return(ID);
     117             :                 }
     118             : {id}            {
     119       92949 :                     yylval.str = scanstr(yytext);
     120      185898 :                     return(ID);
     121             :                 }
     122             : {sid}           {
     123        4167 :                     yytext[strlen(yytext)-1] = '\0'; /* strip off quotes */
     124        4167 :                     yylval.str = scanstr(yytext+1);
     125        8334 :                     yytext[strlen(yytext)] = '"'; /* restore quotes */
     126        4167 :                     return(ID);
     127             :                 }
     128             : 
     129             : .               {
     130           0 :                     elog(ERROR, "syntax error at line %d: unexpected character \"%s\"", yyline, yytext);
     131             :                 }
     132             : 
     133             : 
     134           0 : 
     135           0 : %%
     136           0 : 
     137             : void
     138           0 : yyerror(const char *message)
     139             : {
     140           0 :     elog(ERROR, "%s at line %d", message, yyline);
     141             : }

Generated by: LCOV version 1.11