]> git.proxmox.com Git - mirror_iproute2.git/blame - tc/emp_ematch.y
rdma: Properly mark RDMAtool license
[mirror_iproute2.git] / tc / emp_ematch.y
CommitLineData
311b4145
SH
1%{
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <malloc.h>
5 #include <string.h>
6 #include "m_ematch.h"
7%}
8
9%locations
311b4145
SH
10%token-table
11%error-verbose
edd39792 12%name-prefix "ematch_"
311b4145
SH
13
14%union {
15 unsigned int i;
16 struct bstr *b;
17 struct ematch *e;
18}
19
20%{
737f15f6 21 extern int ematch_lex(void);
5761f04f 22 extern void yyerror(const char *s);
311b4145
SH
23 extern struct ematch *ematch_root;
24 extern char *ematch_err;
25%}
26
27%token <i> ERROR
28%token <b> ATTRIBUTE
29%token <i> AND OR NOT
30%type <i> invert relation
31%type <e> match expr
32%type <b> args
33%right AND OR
34%start input
35%%
36input:
37 /* empty */
38 | expr
39 { ematch_root = $1; }
40 | expr error
41 {
42 ematch_root = $1;
43 YYACCEPT;
44 }
45 ;
46
47expr:
48 match
49 { $$ = $1; }
50 | match relation expr
51 {
52 $1->relation = $2;
53 $1->next = $3;
54 $$ = $1;
55 }
56 ;
57
58match:
59 invert ATTRIBUTE '(' args ')'
60 {
61 $2->next = $4;
62 $$ = new_ematch($2, $1);
63 if ($$ == NULL)
64 YYABORT;
65 }
66 | invert '(' expr ')'
67 {
68 $$ = new_ematch(NULL, $1);
69 if ($$ == NULL)
70 YYABORT;
71 $$->child = $3;
72 }
73 ;
74
75args:
76 ATTRIBUTE
77 { $$ = $1; }
78 | ATTRIBUTE args
79 { $1->next = $2; }
80 ;
81
82relation:
83 AND
84 { $$ = TCF_EM_REL_AND; }
85 | OR
86 { $$ = TCF_EM_REL_OR; }
87 ;
88
89invert:
90 /* empty */
91 { $$ = 0; }
92 | NOT
93 { $$ = 1; }
94 ;
95%%
96
5761f04f 97 void yyerror(const char *s)
311b4145
SH
98 {
99 ematch_err = strdup(s);
100 }