]> git.proxmox.com Git - mirror_iproute2.git/blob - tc/emp_ematch.y
man: dcb-ets: Remove an unnecessary empty line
[mirror_iproute2.git] / tc / emp_ematch.y
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 %union {
10 unsigned int i;
11 struct bstr *b;
12 struct ematch *e;
13 }
14
15 %{
16 extern int ematch_lex(void);
17 extern void yyerror(const char *s);
18 extern struct ematch *ematch_root;
19 extern char *ematch_err;
20 %}
21
22 %token <i> ERROR
23 %token <b> ATTRIBUTE
24 %token <i> AND OR NOT
25 %type <i> invert relation
26 %type <e> match expr
27 %type <b> args
28 %right AND OR
29 %start input
30 %%
31 input:
32 /* empty */
33 | expr
34 { ematch_root = $1; }
35 | expr error
36 {
37 ematch_root = $1;
38 YYACCEPT;
39 }
40 ;
41
42 expr:
43 match
44 { $$ = $1; }
45 | match relation expr
46 {
47 $1->relation = $2;
48 $1->next = $3;
49 $$ = $1;
50 }
51 ;
52
53 match:
54 invert ATTRIBUTE '(' args ')'
55 {
56 $2->next = $4;
57 $$ = new_ematch($2, $1);
58 if ($$ == NULL)
59 YYABORT;
60 }
61 | invert '(' expr ')'
62 {
63 $$ = new_ematch(NULL, $1);
64 if ($$ == NULL)
65 YYABORT;
66 $$->child = $3;
67 }
68 ;
69
70 args:
71 ATTRIBUTE
72 { $$ = $1; }
73 | ATTRIBUTE args
74 { $1->next = $2; }
75 ;
76
77 relation:
78 AND
79 { $$ = TCF_EM_REL_AND; }
80 | OR
81 { $$ = TCF_EM_REL_OR; }
82 ;
83
84 invert:
85 /* empty */
86 { $$ = 0; }
87 | NOT
88 { $$ = 1; }
89 ;
90 %%
91
92 void yyerror(const char *s)
93 {
94 ematch_err = strdup(s);
95 }