method
nullable?
v7.2.3 -
Show latest stable
- Class:
ActionDispatch::Journey::GTG::Builder
nullable?(node)public
No documentation available.
# File actionpack/lib/action_dispatch/journey/gtg/builder.rb, line 66
def nullable?(node)
case node
when Nodes::Group
true
when Nodes::Star
# the default star regex is /(.+)/ which is NOT nullable but since different
# constraints can be provided we must actually check if this is the case or not.
node.regexp.match?("")
when Nodes::Or
node.children.any? { |c| nullable?(c) }
when Nodes::Cat
nullable?(node.left) && nullable?(node.right)
when Nodes::Terminal
!node.left
when Nodes::Unary
nullable?(node.left)
else
raise ArgumentError, "unknown nullable: %s" % node.class.name
end
end