Class: DDQL::TokenType::SubQuery

Inherits:
DDQL::TokenType show all
Defined in:
lib/ddql/token_type.rb

Constant Summary

Constants inherited from DDQL::TokenType

ALL, CURRENCY_LITERAL, FACTOR, FACTOR_PATTERN, INFIXOPERATOR, INTEGER_LITERAL, LBRACE, LPAREN, NESTED_CLOSER, NESTED_CLOSE_PATTERN, NESTED_OPENER, NESTED_OPEN_PATTERN, NUMERIC_LITERAL, POSTFIXOPERATOR, PREFIXOPERATOR, RBRACE, RPAREN, SCI_NUM_LITERAL, SCREEN, SPECIAL_MARKER, STRING_LITERAL, SUB_Q_ALIAS, SUB_Q_EXPR, SUB_Q_FIELDS, SUB_Q_GROUP, SUB_Q_TYPE, WHITESPACE

Instance Attribute Summary

Attributes inherited from DDQL::TokenType

#label, #name, #pattern

Instance Method Summary collapse

Methods inherited from DDQL::TokenType

#==, all_types_pattern, #as_hash, #comparison?, #data_from, #factor?, #group?, #infix?, #interpret, #interpreted_data_from, #literal?, #match?, #postfix?, #prefix?, #screen?, #skipping!, #supports_post_processing?, #trimming!

Constructor Details

#initializeSubQuery

Returns a new instance of SubQuery.



439
440
441
# File 'lib/ddql/token_type.rb', line 439

def initialize
  super(name: :lbrace, pattern: /\{/)
end

Instance Method Details

#expression?Boolean

Returns:

  • (Boolean)


443
444
445
# File 'lib/ddql/token_type.rb', line 443

def expression?
  true
end

#parse(parser, _token, expression: nil) ⇒ Object



447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
# File 'lib/ddql/token_type.rb', line 447

def parse(parser, _token, expression: nil)
  new_expression = parser.parse
  if parser.peek&.supports_post_processing?
    _token, new_expression = parser.peek.post_process(parser: parser, expression: new_expression)
  end

  if expression.nil?
    next_token = parser.peek
    if next_token && (next_token.and? || next_token.or?)
      {
        lstatement: new_expression,
      }
    else
      new_expression
    end
  else
    expression.merge(new_expression)
  end
end