Class: Scim2::Filter::Parser

Inherits:
Racc::Parser
  • Object
show all
Defined in:
lib/scim2/filter/parser.rb

Overview

Implements a SCIM2 compliant event-based parser for query filters. The parser will emit four different events to a handler implemention as it encounters various components within the filter. For reference, see:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(handler = SimpleHandler.new) ⇒ Parser

Returns a new instance of Parser.

Parameters:

  • handler (Handler) (defaults to: SimpleHandler.new)

    a handler object that responds to all four events


20
21
22
23
# File 'lib/scim2/filter/parser.rb', line 20

def initialize(handler = SimpleHandler.new)
  super()
  @handler = handler
end

Instance Attribute Details

#handlerObject (readonly)

Returns the value of attribute handler.


17
18
19
# File 'lib/scim2/filter/parser.rb', line 17

def handler
  @handler
end

Instance Method Details

#next_tokenString

Required by Racc::Parser to emit the next token to the parser. This method should generally not be called directly.

Returns:

  • (String)

    the next token


28
29
30
# File 'lib/scim2/filter/parser.rb', line 28

def next_token
  @lexer.next_token
end

#parse(string) ⇒ Object

Parses a given string input

Parameters:

  • string (String)

    the filter to parse

Returns:

  • (Object)

    returns the last object emitted by the handler


35
36
37
38
39
# File 'lib/scim2/filter/parser.rb', line 35

def parse(string)
  @lexer = Lexer.new
  @lexer.scan_setup(string)
  do_parse
end