LCOV - code coverage report
Current view: top level - root/contrail/src/contrail-analytics/contrail-collector/ruleparser - ruleparserl.ll (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 0 49 0.0 %
Date: 2026-08-03 02:19:58 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
       3             :  */
       4             : 
       5             : %{
       6             : 
       7             : #pragma GCC diagnostic ignored "-Wunused-function"
       8             : #pragma GCC diagnostic ignored "-Wunused-label"
       9             : 
      10             : #include <string>
      11             : #include <errno.h>
      12             : 
      13             : #include "ruleutil.h"
      14             : #include "t_ruleparser.h"
      15             : #include "ruleglob.h"
      16             : 
      17             : #include "ruleparsery.hh"
      18             : 
      19           0 : void rule_eng_reserved_keyword(char* keyword) {
      20           0 :   yyerror("Cannot use reserved language keyword: \"%s\"\n", keyword);
      21           0 :   exit(1);
      22             : }
      23             : 
      24           0 : void integer_overflow(char* text) {
      25           0 :   yyerror("This integer is too big: \"%s\"\n", text);
      26           0 :   exit(1);
      27             : }
      28             : 
      29           0 : void unexpected_token(char* text) {
      30           0 :   yyerror("Unexpected token in input: \"%s\"\n", text);
      31           0 :   exit(1);
      32             : }
      33             : 
      34             : %}
      35             : 
      36             : /**
      37             :  * Provides the yylineno global, useful for debugging output
      38             :  */
      39             : %option lex-compat
      40             : 
      41             : /**
      42             :  * Our inputs are all single files, so no need for yywrap
      43             :  */
      44             : %option noyywrap
      45             : 
      46             : /**
      47             :  * We don't use it, and it fires up warnings at -Wall
      48             :  */
      49             : %option nounput
      50             : 
      51             : /**
      52             :  * Helper definitions, comments, constants, and whatnot
      53             :  */
      54             : 
      55             : st_identifier    ([a-zA-Z_0-9][\.a-zA-Z_0-9]*)
      56             : whitespace    ([ \t\r\n]*)
      57             : sillycomm     ("/*""*"*"*/")
      58             : multicomm     ("/*"[^*]"/"*([^*/]|[^*]"/"|"*"[^/])*"*"*"*/")
      59             : doctext       ("/**"([^*/]|[^*]"/"|"*"[^/])*"*"*"*/")
      60             : comment       ("//"[^\n]*)
      61             : unixcomment   ("#"[^\n]*)
      62             : symbol        ([:;\-\,\{\}\(\)\[\]])
      63             : symbolcmp     ([=<>|])
      64             : literal_begin (['\"])
      65             : 
      66             : %%
      67             : 
      68             : {whitespace}         { /* do nothing */                 }
      69           0 : {sillycomm}          { /* do nothing */                 }
      70           0 : {multicomm}          { /* do nothing */                 }
      71           0 : {comment}            { /* do nothing */                 }
      72           0 : {unixcomment}        { /* do nothing */                 }
      73           0 : 
      74           0 : {symbolcmp} {
      75           0 :   yylval.symbol = yytext[0];
      76           0 :   return tok_symbolcmp;
      77             : }
      78             : 
      79           0 : {symbol}             { return yytext[0];                }
      80           0 : "*"                  { return yytext[0];                }
      81           0 : 
      82           0 : "include"            { return tok_include;              }
      83           0 : "Rule"               { return tok_rule;                 }
      84           0 : "For"                { return tok_for;                  }
      85           0 : "eq"                 { return tok_eq;                   }
      86           0 : "match"              { return tok_match;                }
      87           0 : "and"                { return tok_and;                  }
      88           0 : "action"             { return tok_action;               }
      89           0 : "in"                 { return tok_in;                   }
      90           0 : "msgtype"            { return tok_msgtype;              }
      91           0 : "context"            { return tok_context;              }
      92           0 : 
      93           0 : {st_identifier} {
      94           0 :   yylval.id = strdup(yytext);
      95           0 :   return tok_st_identifier;
      96             : }
      97             : 
      98           0 : {doctext} {
      99             :  /* This does not show up in the parse tree. */
     100             :  /* Rather, the parser will grab it out of the global. */
     101           0 :   if (g_parse_mode == PROGRAM) {
     102           0 :     clear_doctext();
     103           0 :     g_doctext = strdup(yytext + 3);
     104           0 :     g_doctext[strlen(g_doctext) - 2] = '\0';
     105           0 :     g_doctext = clean_up_doctext(g_doctext);
     106           0 :     g_doctext_lineno = yylineno;
     107             :   }
     108             : }
     109           0 : 
     110           0 : . {
     111           0 :   unexpected_token(yytext);
     112             : }
     113           0 : 
     114           0 : 
     115             : . {
     116             :   /* Catch-all to let us catch "*" in the parser. */
     117           0 :   return (int) yytext[0];
     118             : }
     119             : 
     120           0 : %%
     121           0 : 

Generated by: LCOV version 1.14