Class: DDQL::TokenType::SubQueryExpression
- Inherits:
-
DDQL::TokenType
- Object
- DDQL::TokenType
- DDQL::TokenType::SubQueryExpression
- 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
Instance Method Summary collapse
- #as_hash(data) ⇒ Object
-
#initialize ⇒ SubQueryExpression
constructor
A new instance of SubQueryExpression.
- #parse(parser, token, expression: nil) ⇒ Object
Methods inherited from DDQL::TokenType
#==, all_types_pattern, #comparison?, #data_from, #expression?, #factor?, #group?, #infix?, #interpret, #interpreted_data_from, #literal?, #match?, #postfix?, #prefix?, #screen?, #skipping!, #supports_post_processing?, #trimming!
Constructor Details
#initialize ⇒ SubQueryExpression
Returns a new instance of SubQueryExpression.
503 504 505 |
# File 'lib/ddql/token_type.rb', line 503 def initialize super(name: :sub_query_expression, pattern: /expression:\s*(?<sub_query_expression>[^\{\}#{Regexp.escape(TokenType::NESTED_OPEN_PATTERN)}#{Regexp.escape(TokenType::NESTED_CLOSE_PATTERN)}]{5,})\s*,?\s*/) end |
Instance Method Details
#as_hash(data) ⇒ Object
507 508 509 |
# File 'lib/ddql/token_type.rb', line 507 def as_hash(data) {name => data} end |
#parse(parser, token, expression: nil) ⇒ Object
511 512 513 514 515 516 517 518 519 520 521 522 523 |
# File 'lib/ddql/token_type.rb', line 511 def parse(parser, token, expression: nil) data = token.data.strip if data.start_with? TokenType::NESTED_OPEN_PATTERN sub_data = data[1..(data.index(TokenType::NESTED_CLOSE_PATTERN))] data = parser.class.parse sub_data end if expression.nil? || expression.keys != i[agg sub_query_fields sub_query_type] as_hash(data).merge parser.parse else expression.merge(as_hash(data)) end end |