Class: DDQL::TokenType::Group

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, #expression?, #factor?, #infix?, #interpret, #interpreted_data_from, #literal?, #match?, #postfix?, #prefix?, #screen?, #skipping!, #supports_post_processing?, #trimming!

Constructor Details

#initializeGroup

Returns a new instance of Group.



231
232
233
# File 'lib/ddql/token_type.rb', line 231

def initialize
  super(name: :lparen, pattern: /\((?=[^%])/)
end

Instance Method Details

#group?Boolean

Returns:

  • (Boolean)


235
236
237
# File 'lib/ddql/token_type.rb', line 235

def group?
  true
end

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



239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
# File 'lib/ddql/token_type.rb', line 239

def parse(parser, _token, expression: nil)
  new_expression = parser.parse
  parser.consume TokenType::RPAREN

  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