Class: Jamespath::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/jamespath/parser.rb

Overview

# Grammar

“‘abnf expression : sub_expression | index_expression

| or_expression | identifier | '*'
| multi_select_list | multi_select_hash;

sub_expression : expression ‘.’ expression; or_expression : expression ‘||’ expression; index_expression : expression bracket_specifier | bracket_specifier; multi_select_list : ‘[’ non_branched_expr ‘]’; multi_select_hash : ‘keyval_expr ‘’; keyval_expr : identifier ‘:’ non_branched_expr; non_branched_expr : identifier

| non_branched_expr '.' identifier
| non_branched_expr '[' number ']';

bracket_specifier : ‘[’ number ‘]’ | ‘[’ ‘*’ ‘]’; “‘

Instance Method Summary collapse

Instance Method Details

#parse(source) ⇒ Array(Symbol, Object)

Parses an expression into a set of instructions to be executed by the VM.

Parameters:

  • source (String)

    the expression to parse

Returns:

  • (Array(Symbol, Object))

    a set of instructions

See Also:



28
29
30
31
32
33
34
# File 'lib/jamespath/parser.rb', line 28

def parse(source)
  @tokens = Tokenizer.new.tokenize(source)
  @idx = 0
  @instructions = []
  parse_expression
  @instructions
end