added lwes-filter-listener
[lwes.git] / src / lwes_esf_parser.l
blob9802dceae9c1f117ec313e9d7ec1c8fdbaac9dcc
1 %{
2 /*
3  * This is the lexical analyser for the Event Specification file
4  */
6 #define YYSTYPE const char*
8 #include "lwes_esf_parser.h"
9 #include "lwes_esf_parser_y.h"  /* token codes from the parser */
11 #define YY_NO_UNPUT
13 #undef YY_DECL
14 #define YY_DECL int lweslex( YYSTYPE *lvalp, void *param)
16 /* this fixes a problem in flex where compiling with -Wall and FORTIFY_SOURCE
17    fails since the ECHO macro ignores the output of fwrite().  
18    So we assign the output to a static variable but don't use it so 
19    the compile suceeds */
21 static int __lwesfwriteout;
22 #define ECHO _fwout = fwrite( yytext, yyleng, 1, yyout )
25 /* function prototypes */
26 int lweslex(YYSTYPE *lvalp, void *param);
27 void lweslexdestroy (void);
29 void
30 lweslexdestroy
31   (void)
33 /* FIXME: This doesn't work with multiple parsers, I think I need to
34    experiment with reentrancy */
35   lwes_delete_buffer (YY_CURRENT_BUFFER);
41 %option noyywrap
45 \n              { ((struct lwes_parser_state *) param)->lineno++; }
46 uint16          { 
47                   *lvalp = (YYSTYPE)lwestext;
48                   return(YY_UINT16);
49                 }
50 int16           {
51                   *lvalp = (YYSTYPE)lwestext;
52                   return(YY_INT16);
53                 }
54 uint32          {
55                   *lvalp = (YYSTYPE)lwestext;
56                   return(YY_UINT32);
57                 }
58 int32           {
59                   *lvalp = (YYSTYPE)lwestext;
60                   return(YY_INT32);
61                 }
62 string          {
63                   *lvalp = (YYSTYPE)lwestext;
64                   return(YY_STRING);
65                 }
66 ip_addr         {
67                   *lvalp = (YYSTYPE)lwestext;
68                   return(YY_IP_ADDR);
69                 }
70 int64           {
71                   *lvalp = (YYSTYPE)lwestext;
72                   return(YY_INT64);
73                 }
74 uint64          {
75                   *lvalp = (YYSTYPE)lwestext;
76                   return(YY_UINT64);
77                 }
78 boolean         {
79                   *lvalp = (YYSTYPE)lwestext;
80                   return(YY_BOOLEAN);
81                 }
82 [a-zA-Z0-9_:]+  {
83                    *lvalp = (YYSTYPE)lwestext;
84                   if (((struct lwes_parser_state *) param)->in_event)
85                     return(ATTRIBUTEWORD);
86                   else
87                     return(EVENTWORD);
88                 }
89 "{"             {
90                   ((struct lwes_parser_state *) param)->in_event = 1;
91                   return '{';
92                 }
93 "}"             {
94                   ((struct lwes_parser_state *) param)->in_event = 0;
95                   return '}';
96                 }
97 ";"             {
98                   return ';';
99                 }
100 "#"[^\n]*       /* eat up one-line comments */
101 .               ;