class JMESPath::TokenStream

@api private

def _next

def _next
  @position += 1
  @token = @tokens[@position] || Token::NULL_TOKEN
end

def initialize(expression, tokens)

Parameters:
  • tokens (Array) --
  • expression (String) --
def initialize(expression, tokens)
  @expression = expression
  @tokens = tokens
  @token = nil
  @position = -1
  self.next
end

def inspect

Other tags:
    Api: - private
def inspect
  str = []
  @tokens.each do |token|
    str << '%3d  %-15s %s' %
           [token.position, token.type, token.value.inspect]
  end
  str.join("\n")
end

def lookahead(count)

def lookahead(count)
  @tokens[@position + count] || Token::NULL_TOKEN
end

def next(options = {})

Options Hash: (**options)
  • :match (Array) -- Requires the next token to be
def next(options = {})
  validate_match(_next, options[:match])
end

def validate_match(token, match)

def validate_match(token, match)
  if match && !match.include?(token.type)
    raise Errors::SyntaxError, 'type missmatch'
  else
    token
  end
end