Class: JMESPath::Parser Private
- Inherits:
-
Object
- Object
- JMESPath::Parser
- Defined in:
- lib/jmespath/parser.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- AFTER_DOT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Set.new([ Lexer::T_IDENTIFIER, # foo.bar Lexer::T_QUOTED_IDENTIFIER, # foo."bar" Lexer::T_STAR, # foo.* Lexer::T_LBRACE, # foo{a: 0} Lexer::T_LBRACKET, # foo[1] Lexer::T_FILTER, # foo.[?bar==10] ])
- NUM_COLON_RBRACKET =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Set.new([ Lexer::T_NUMBER, Lexer::T_COLON, Lexer::T_RBRACKET, ])
- COLON_RBRACKET =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Set.new([ Lexer::T_COLON, Lexer::T_RBRACKET, ])
- CURRENT_NODE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Nodes::Current.new
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Parser
constructor
private
A new instance of Parser.
- #method_missing(method_name, *args) ⇒ Object private
- #parse(expression) ⇒ Object private
Constructor Details
#initialize(options = {}) ⇒ Parser
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Parser.
30 31 32 |
# File 'lib/jmespath/parser.rb', line 30 def initialize( = {}) @lexer = [:lexer] || Lexer.new end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
47 48 49 50 51 52 53 |
# File 'lib/jmespath/parser.rb', line 47 def method_missing(method_name, *args) if matches = method_name.match(/^(nud_|led_)(.*)/) raise Errors::SyntaxError, "unexpected token #{matches[2]}" else super end end |
Instance Method Details
#parse(expression) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/jmespath/parser.rb', line 35 def parse(expression) tokens = @lexer.tokenize(expression) stream = TokenStream.new(expression, tokens) result = expr(stream) if stream.token.type != Lexer::T_EOF raise Errors::SyntaxError, "expected :eof got #{stream.token.type}" else result end end |