back to topotato report
topotato coverage report
Current view: top level - lib - command_lex.l (source / functions) Hit Total Coverage
Test: test_bgp_aspath_zero.py::BGPAggregatorZero Lines: 22 24 91.7 %
Date: 2023-02-24 18:36:48 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /*
       2             :  * Command format string lexer for CLI backend.
       3             :  *
       4             :  * --
       5             :  * Copyright (C) 2015 Cumulus Networks, Inc.
       6             :  *
       7             :  * This file is part of GNU Zebra.
       8             :  *
       9             :  * GNU Zebra is free software; you can redistribute it and/or modify it
      10             :  * under the terms of the GNU General Public License as published by the
      11             :  * Free Software Foundation; either version 2, or (at your option) any
      12             :  * later version.
      13             :  *
      14             :  * GNU Zebra is distributed in the hope that it will be useful, but
      15             :  * WITHOUT ANY WARRANTY; without even the implied warranty of
      16             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      17             :  * General Public License for more details.
      18             :  *
      19             :  * You should have received a copy of the GNU General Public License
      20             :  * along with GNU Zebra; see the file COPYING.  If not, write to the Free
      21             :  * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
      22             :  * 02111-1307, USA.
      23             :  */
      24             : 
      25             : %top{
      26             : #ifdef HAVE_CONFIG_H
      27             : #include "config.h"
      28             : #endif
      29             : }
      30             : %{
      31             : /* ignore flex generated code in static analyzer */
      32             : #ifndef __clang_analyzer__
      33             : 
      34             : /* ignore harmless bugs in old versions of flex */
      35             : #pragma GCC diagnostic ignored "-Wsign-compare"
      36             : #pragma GCC diagnostic ignored "-Wmissing-prototypes"
      37             : 
      38             : #include "lib/command_parse.h"
      39             : 
      40             : #define YY_USER_ACTION yylloc->last_column += yyleng;
      41             : #define LOC_STEP do { if (yylloc) { \
      42             :         yylloc->first_column = yylloc->last_column; \
      43             :         yylloc->first_line = yylloc->last_line; \
      44             :         } } while(0)
      45             : %}
      46             : 
      47             : IPV4            A\.B\.C\.D
      48             : IPV4_PREFIX     A\.B\.C\.D\/M
      49             : IPV6            X:X::X:X
      50             : IPV6_PREFIX     X:X::X:X\/M
      51             : MAC             X:X:X:X:X:X
      52             : MAC_PREFIX      X:X:X:X:X:X\/M
      53             : VARIABLE        [A-Z][-_A-Z:0-9]+
      54             : WORD            (\-|\+)?[a-zA-Z0-9\*][-+_a-zA-Z0-9\*]*
      55             : NUMBER          (\-|\+)?[0-9]{1,20}
      56             : RANGE           \({NUMBER}[ ]?\-[ ]?{NUMBER}\)
      57             : 
      58             : /* yytext shall be a pointer */
      59             : %pointer
      60             : %option noyywrap
      61             : %option nounput
      62             : %option noinput
      63             : %option outfile="lib/command_lex.c"
      64             : %option header-file="lib/command_lex.h"
      65             : %option prefix="cmd_yy"
      66             : %option reentrant
      67             : %option bison-bridge
      68             : %option bison-locations
      69             : 
      70             : %%
      71             : %{
      72             :                 LOC_STEP;
      73      163408 : %}
      74             : 
      75             : [ \t]+          LOC_STEP /* ignore whitespace */;
      76       21352 : {IPV4}          {yylval->string = XSTRDUP(MTYPE_LEX, yytext); return IPV4;}
      77        2092 : {IPV4_PREFIX}   {yylval->string = XSTRDUP(MTYPE_LEX, yytext); return IPV4_PREFIX;}
      78         256 : {IPV6}          {yylval->string = XSTRDUP(MTYPE_LEX, yytext); return IPV6;}
      79        3970 : {IPV6_PREFIX}   {yylval->string = XSTRDUP(MTYPE_LEX, yytext); return IPV6_PREFIX;}
      80         494 : {MAC}           {yylval->string = XSTRDUP(MTYPE_LEX, yytext); return MAC;}
      81        1964 : {MAC_PREFIX}    {yylval->string = XSTRDUP(MTYPE_LEX, yytext); return MAC_PREFIX;}
      82         248 : {VARIABLE}      {yylval->string = XSTRDUP(MTYPE_LEX, yytext); return VARIABLE;}
      83        3965 : {WORD}          {yylval->string = XSTRDUP(MTYPE_LEX, yytext); return WORD;}
      84       27854 : {RANGE}         {yylval->string = XSTRDUP(MTYPE_LEX, yytext); return RANGE;}
      85        5714 : !\[             {yylval->string = NULL; return EXCL_BRACKET;}
      86       27844 : .               {return yytext[0];}
      87        1835 : %%
      88           0 : 
      89       26749 : static YY_BUFFER_STATE buffer;
      90           0 : 
      91             : void set_lexer_string (yyscan_t *scn, const char *string)
      92        6161 : {
      93             :   *scn = NULL;
      94        6161 :   yylex_init(scn);
      95        6161 :   buffer = yy_scan_string (string, *scn);
      96        6161 : }
      97        6161 : 
      98             : void cleanup_lexer (yyscan_t *scn)
      99        6161 : {
     100             :   // yy_delete_buffer (buffer, *scn);
     101             :   yylex_destroy(*scn);
     102        6161 : }
     103        6161 : 
     104             : #endif /* __clang_analyzer__ */

Generated by: LCOV version v1.16-topotato