lib/dnf/boolean_expression.rb in dnf-0.2.0 vs lib/dnf/boolean_expression.rb in dnf-0.2.1
- old
+ new
@@ -38,9 +38,10 @@
raise ExpressionSyntaxError, "Invalid token: #{token}"
end
end
def validate_syntax(tokens)
+ raise ExpressionSyntaxError, "Unexpected start: #{tokens.first}" unless tokens.first.match?(/\A#{config[:variable_regex].source}\z/) || tokens.first == config[:not_symbol] || tokens.first == '('
tokens.each_cons(2) do |prev, curr|
case prev
when config[:variable_regex], ')'
raise ExpressionSyntaxError, "Unexpected token: #{prev} #{curr}" unless curr == config[:and_symbol] || curr == config[:or_symbol] || curr == ')'
when config[:not_symbol]