class Regexp::Expression::Base
def one_of?(scope, top = true)
exp.one_of?({meta: [:dot], set: :*})
# meta dots and any set tokens
exp.one_of?(:meta => [:dot, :alternation])
# meta dots and alternations
exp.one_of?(:meta => :*)
# any expression of type meta
exp.one_of?(:group)
# like exp.type?(:group)
exp.one_of?(:*) # always true
# any expression
expression.
from a hash, it will be checked against the token of the
type of the expression. If it's being called for a value
a symbol then it will always be checked against the
the level of the call. If one_of? is called directly with
. A symbol: matches the expression's token or type, depending on
evaluate the key's value.
case, when the scope is a hash, one_of? calls itself to
and the value is either a symbol or an array. In this
. A hash: Where the key is interpreted as the expression type
of the expression's token.
. An array: Interpreted as a set of tokens, tested for inclusion
A scope spec can be one of:
Test if this expression matches an entry in the given scope spec.
def one_of?(scope, top = true) case scope when Array if scope.include?(:*) return (scope.include?(token) or scope.include?(:*)) else return scope.include?(token) end when Hash if scope.has_key?(:*) test_type = scope.has_key?(type) ? type : :* return one_of?(scope[test_type], false) else return (scope.has_key?(type) and one_of?(scope[type], false)) end when Symbol return true if scope == :* return is?(scope) unless top return type?(scope) if top else raise "Array, Hash, or Symbol expected, #{scope.class.name} given" end false end