condition := '(' value ')' | operator := | << | < | <= | > | >> | >= | = | % | ~
()
| 172 | // condition := '(' <operator> value ')' | |
| 173 | // operator := | << | < | <= | > | >> | >= | = | % | ~ |
| 174 | func (p *parser) Condition() (operator itemType, value string) { |
| 175 | if p.input.Current().typ != itemLeftParen { |
| 176 | return |
| 177 | } |
| 178 | p.input.Consume() |
| 179 | |
| 180 | if p.input.Current().typ == itemLt || |
| 181 | p.input.Current().typ == itemGt || |
| 182 | p.input.Current().typ == itemLtEq || |
| 183 | p.input.Current().typ == itemGtEq || |
| 184 | p.input.Current().typ == itemEq || |
| 185 | p.input.Current().typ == itemPatMatch || |
| 186 | p.input.Current().typ == itemRegexp { |
| 187 | operator = p.input.Current().typ |
| 188 | p.input.Consume() |
| 189 | } else { |
| 190 | operator = itemEq |
| 191 | } |
| 192 | |
| 193 | if p.input.Current().typ != itemString { |
| 194 | panic(fmt.Sprintf("unexpected token %s: expecting value", p.input.Current())) |
| 195 | } |
| 196 | value = p.input.Current().val |
| 197 | p.input.Consume() |
| 198 | |
| 199 | if p.input.Current().typ != itemRightParen { |
| 200 | panic(fmt.Sprintf("unexpected token %s: expecting ')'", p.input.Current())) |
| 201 | } |
| 202 | p.input.Consume() |
| 203 | |
| 204 | return |
| 205 | } |
| 206 | |
| 207 | // arch_condition := '{' arch '}' | |
| 208 | func (p *parser) ArchCondition() (arch string) { |