lib/yoga/parser/helpers.rb in yoga-0.4.1 vs lib/yoga/parser/helpers.rb in yoga-0.4.2
- old
+ new
@@ -171,12 +171,12 @@
# @param join [::Symbol, nil] The token that joins each of the
# children. This is the comma between arguments.
# @return [::Array] The collected nodes from the yielding process.
def collect(ending, join = nil)
children = []
- join = Utils.flatten_into_set([join]) if join
- ending = Utils.flatten_into_set([ending]) if ending
+ join = Utils.flatten_into_set(join) if join
+ ending = Utils.flatten_into_set(ending) if ending
return [] if (ending && peek?(ending)) || (!ending && !join)
children << yield
@@ -194,13 +194,12 @@
# Checks to see if any of the given kinds includes the next token.
#
# @param tokens [<::Symbol>] The possible kinds.
# @return [::Boolean]
- def peek?(*tokens)
- tokens = Utils.flatten_into_set(tokens)
- tokens.include?(peek.kind)
+ def peek?(tokens)
+ Utils.flatten_into_set(tokens).include?(peek.kind)
end
# Peeks out to a specific point in the future to match. This is an
# expensive operation.
#
@@ -208,12 +207,11 @@
# @see peek_out
# @param to [::Numeric] The distance to peek to.
# @param tokens [<::Symbol>] The kinds of tokens to check for.
# @return [::Boolean]
def peek_out?(to, tokens)
- tokens = Utils.flatten_into_set([tokens])
- tokens.include?(peek_out(to).kind)
+ Utils.flatten_into_set(tokens).include?(peek_out(to).kind)
end
# Shifts to the next token, and returns the old token.
#
# @return [Yoga::Token]
@@ -227,13 +225,13 @@
# an expected token, it shifts, returning the token; otherwise,
# it {#error}s with the token information.
#
# @param tokens [<::Symbol>] The expected tokens.
# @return [Yoga::Token]
- def expect(*tokens)
+ def expect(tokens)
tokens = Utils.flatten_into_set(tokens)
- return shift if peek?(*tokens)
- error(tokens.flatten)
+ return shift if peek?(tokens)
+ error(tokens)
end
# Retrieves the first set for the given node name.
#
# @param name [::Symbol]