]>
Commit | Line | Data |
---|---|---|
1ab84bf3 QY |
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 | ||
92055a92 | 25 | %{ |
2a23ca6e | 26 | #include "command_parse.h" |
92055a92 | 27 | |
2a23ca6e | 28 | extern void set_buffer_string(const char *); |
92055a92 QY |
29 | %} |
30 | ||
b3899769 | 31 | WORD (\-|\+)?[a-z\*][-+_a-zA-Z0-9\*]* |
92055a92 QY |
32 | IPV4 A\.B\.C\.D |
33 | IPV4_PREFIX A\.B\.C\.D\/M | |
34 | IPV6 X:X::X:X | |
35 | IPV6_PREFIX X:X::X:X\/M | |
1a8c390d | 36 | VARIABLE [A-Z][-_a-zA-Z:0-9]+ |
b3899769 | 37 | NUMBER (\-|\+)?[0-9]{1,20} |
ef955a80 | 38 | RANGE \({NUMBER}[ ]?\-[ ]?{NUMBER}\) |
92055a92 QY |
39 | |
40 | /* yytext shall be a pointer */ | |
41 | %pointer | |
42 | %option noyywrap | |
2a23ca6e QY |
43 | %option nounput |
44 | %option noinput | |
45 | %option outfile="command_lex.c" | |
92055a92 QY |
46 | |
47 | %% | |
92055a92 | 48 | [ /t] /* ignore whitespace */; |
de9d7e4f QY |
49 | {WORD} {yylval.string = XSTRDUP(MTYPE_TMP, yytext); return WORD;} |
50 | {IPV4} {yylval.string = XSTRDUP(MTYPE_TMP, yytext); return IPV4;} | |
51 | {IPV4_PREFIX} {yylval.string = XSTRDUP(MTYPE_TMP, yytext); return IPV4_PREFIX;} | |
52 | {IPV6} {yylval.string = XSTRDUP(MTYPE_TMP, yytext); return IPV6;} | |
53 | {IPV6_PREFIX} {yylval.string = XSTRDUP(MTYPE_TMP, yytext); return IPV6_PREFIX;} | |
54 | {VARIABLE} {yylval.string = XSTRDUP(MTYPE_TMP, yytext); return VARIABLE;} | |
e648e61a QY |
55 | {NUMBER} { |
56 | char *endptr; | |
51fc9379 | 57 | yylval.number = strtoimax(yytext, &endptr, 10); |
e648e61a QY |
58 | return NUMBER; |
59 | } | |
de9d7e4f | 60 | {RANGE} {yylval.string = XSTRDUP(MTYPE_TMP, yytext); return RANGE;} |
92055a92 QY |
61 | . {return yytext[0];} |
62 | %% | |
2a23ca6e QY |
63 | |
64 | void | |
65 | set_buffer_string(const char *string) | |
66 | { | |
67 | yy_scan_string(string); | |
68 | } |