2014-12-17 06:58:39 +00:00
|
|
|
package token
|
|
|
|
|
2014-12-17 18:57:05 +00:00
|
|
|
// actionSet is a special type of stringSet.
|
|
|
|
type actionSet struct {
|
2015-01-06 02:21:03 +00:00
|
|
|
stringSet
|
2014-12-17 06:58:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 18:57:05 +00:00
|
|
|
func newActionSet(actions ...string) actionSet {
|
2015-01-06 02:21:03 +00:00
|
|
|
return actionSet{newStringSet(actions...)}
|
2014-12-17 06:58:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 18:57:05 +00:00
|
|
|
// Contains calls StringSet.Contains() for
|
2014-12-17 06:58:39 +00:00
|
|
|
// either "*" or the given action string.
|
2015-01-06 02:21:03 +00:00
|
|
|
func (s actionSet) contains(action string) bool {
|
|
|
|
return s.stringSet.contains("*") || s.stringSet.contains(action)
|
|
|
|
}
|
|
|
|
|
|
|
|
// contains returns true if q is found in ss.
|
|
|
|
func contains(ss []string, q string) bool {
|
|
|
|
for _, s := range ss {
|
|
|
|
if s == q {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
2014-12-17 06:58:39 +00:00
|
|
|
}
|
2022-09-27 13:34:26 +00:00
|
|
|
|
|
|
|
// containsAny returns true if any of q is found in ss.
|
|
|
|
func containsAny(ss []string, q []string) bool {
|
|
|
|
for _, s := range ss {
|
|
|
|
if contains(q, s) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|