File: fredef

package info (click to toggle)
tcng 10b-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 3,632 kB
  • ctags: 2,515
  • sloc: ansic: 19,038; pascal: 4,640; yacc: 2,619; sh: 1,908; perl: 1,546; lex: 772; makefile: 755
file content (129 lines) | stat: -rw-r--r-- 2,955 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# fields can be redefined (1/3) -----------------------------------------------
tcc -xif:err 2>&1 | grep '^match'
field f = raw[0];
field f = raw[1];

prio {
    class if f == 0;
}
EOF
match 0:8:8=0x00 action 1
match action 0
# fields can be redefined (2/3) -----------------------------------------------
tcc -xif:err 2>&1 | grep '^match'
field f = raw[1] if raw[0] == 1;
field f = raw[2];

prio {
    class if f == 0;
}
EOF
match 0:16:8=0x00 action 1
match action 0
# fields can be redefined (3/3) -----------------------------------------------
tcc -xif:err 2>&1 | grep '^match'
field f = raw[1];
field f = raw[2] if raw[0] == 2;

prio {
    class if f == 0;
}
EOF
match 0:0:8=0x02 0:16:8=0x00 action 1
match action 0
# field redefinition is transitive --------------------------------------------
tcc -xif:err 2>&1 | grep '^match'
field first = raw[2];
field second = first[2];
field first = raw[4];

prio {
    class if second == 0;
}
EOF
match 0:48:8=0x00 action 1
match action 0
# field redefinition is loop-free ---------------------------------------------
tcc 2>&1
field first = raw[2];
field second = first[2];
field first = second[0];
EOF
ERROR
<stdin>:3: field "second" defined after redefined field near ";"
# fields can be redefined in devices ------------------------------------------
tcc -xif:err 2>&1 | grep 'action 1$'
field f = raw[1];

eth0 {
    prio {
	class if f == 0;
    }
}

eth1 {
    field f = raw[0];	// MUST be after the device name
    prio {
	class if f == 0;
    }
}
EOF
match 0:8:8=0x00 action 1
match 0:0:8=0x00 action 1
# fields can be redefined between classes -------------------------------------
tcc -xif:err 2>&1 | grep 'action [12]$'
field f = raw[0];

prio {
    class if f == 0;
    field f = raw[1];
    class if f == 0;
}
EOF
match 0:0:8=0x00 action 1
match 0:8:8=0x00 action 2
# fields can't be redefined between if clauses (wrong syntax) -----------------
tcc 2>&1
field f = raw[0];

prio {
    class
	if f == 0;
	field f = raw[1];	// there are no assignments between if
	if f == 0;		// selectors
}
EOF
ERROR
<stdin>:7: "if" anchor doesn't work yet and will be re-designed near "if"
# "field ... if" has precedence over "if ..." ---------------------------------
tcc -xif:err 2>&1 | grep 'action 1$'
prio {
    field f = raw[1] if raw[0] == 1;
    class
	if f == 0;
}
EOF
match 0:0:16=0x0100 action 1
# can use "field ... if 1" to change precedence -------------------------------
tcc 2>&1
field f = raw[0];

prio {
    class
	if f == 0;
    field f = raw[1] if 1;	// there are no assignments between if
    if whatever;		// selectors, so adding the field definition
}				// makes the next if an "if anchor"
EOF
ERROR
<stdin>:7: "if" anchor doesn't work yet and will be re-designed near "if"
# "field ... if 1" actually works ---------------------------------------------
tcc -xif:err 2>&1 | grep '^match'
field f = raw[0] if 1;

prio {
    class if f == 0;
}
EOF
match 0:0:8=0x00 action 1
match action 0