class JMESPath::TokenStream
@api private
Attributes
@return [String<JMESPath>]
@return [Integer]
@return [Token]
Public Class Methods
Source
# File lib/jmespath/token_stream.rb, line 7 def initialize(expression, tokens) @expression = expression @tokens = tokens @token = nil @position = -1 self.next end
@param [String<JMESPath>] expression @param [Array<Token>] tokens
Public Instance Methods
Source
# File lib/jmespath/token_stream.rb, line 35 def inspect str = [] @tokens.each do |token| str << '%3d %-15s %s' % [token.position, token.type, token.value.inspect] end str.join("\n") end
@api private
Source
# File lib/jmespath/token_stream.rb, line 30 def lookahead(count) @tokens[@position + count] || Token::NULL_TOKEN end
Source
# File lib/jmespath/token_stream.rb, line 26 def next(options = {}) validate_match(_next, options[:match]) end
@option options [Array<Symbol>] :match Requires the next token to be
one of the given symbols or an error is raised.
Private Instance Methods
Source
# File lib/jmespath/token_stream.rb, line 46 def _next @position += 1 @token = @tokens[@position] || Token::NULL_TOKEN end
Source
# File lib/jmespath/token_stream.rb, line 51 def validate_match(token, match) if match && !match.include?(token.type) raise Errors::SyntaxError, 'type missmatch' else token end end