]> git.proxmox.com Git - mirror_frr.git/blob - lib/command_lex.l
45f8f8e63691df1d2d5445c0fc1c12304d6faf7e
[mirror_frr.git] / lib / command_lex.l
1 %{
2 #include "command_parse.h"
3
4 extern void set_buffer_string(const char *);
5 %}
6
7 WORD [a-z][-_a-z0-9]+
8 IPV4 A\.B\.C\.D
9 IPV4_PREFIX A\.B\.C\.D\/M
10 IPV6 X:X::X:X
11 IPV6_PREFIX X:X::X:X\/M
12 VARIABLE [A-Z][A-Z_]+
13 NUMBER [0-9]{1,20}
14 RANGE \({NUMBER}\-{NUMBER}\)
15
16 /* yytext shall be a pointer */
17 %pointer
18 %option noyywrap
19 %option nounput
20 %option noinput
21 %option outfile="command_lex.c"
22
23 %%
24 [ /t] /* ignore whitespace */;
25 {WORD} {yylval.string = strdup(yytext); return WORD;}
26 {IPV4} {yylval.string = strdup(yytext); return IPV4;}
27 {IPV4_PREFIX} {yylval.string = strdup(yytext); return IPV4_PREFIX;}
28 {IPV6} {yylval.string = strdup(yytext); return IPV6;}
29 {IPV6_PREFIX} {yylval.string = strdup(yytext); return IPV6_PREFIX;}
30 {VARIABLE} {yylval.string = strdup(yytext); return VARIABLE;}
31 {NUMBER} {yylval.integer = atoi(yytext); return NUMBER;}
32 {RANGE} {yylval.string = strdup(yytext); return RANGE;}
33 . {return yytext[0];}
34 %%
35
36 void
37 set_buffer_string(const char *string)
38 {
39 yy_scan_string(string);
40 }