Class: LogStashCompilerLSCLGrammar::LogStash::Compiler::LSCL::AST::RegexpExpression

Inherits:
Node
  • Object
show all
Defined in:
lib/logstash/compiler/lscl.rb

Constant Summary

Constants included from Helpers

Helpers::AND_METHOD, Helpers::BOOLEAN_DSL_METHOD_SIGNATURE, Helpers::NAND_METHOD, Helpers::OR_METHOD, Helpers::XOR_METHOD

Instance Method Summary collapse

Methods inherited from Node

#section_type

Methods included from Helpers

#base_id, #base_protocol, #base_source_with_metadata, #base_source_with_metadata=, #compose, #compose_for, #jdsl, jdsl, #line_and_column, #source_meta

Instance Method Details

#exprObject



467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
# File 'lib/logstash/compiler/lscl.rb', line 467

def expr
  selector, operator_method, regexp = recursive_select(
    Selector,
    LogStash::Compiler::LSCL::AST::RegExpOperator,
    LogStash::Compiler::LSCL::AST::RegExp,
    LogStash::Compiler::LSCL::AST::String # Strings work as rvalues! :p
  ).map(&:expr)

  # Handle string rvalues, they just get turned into regexps
  # Maybe we really shouldn't handle these anymore...
  if regexp.class == org.logstash.config.ir.expression.ValueExpression
    regexp = jdsl.eRegex(source_meta, regexp.get)
  end

  raise "Expected a selector in #{text_value}!" unless selector
  raise "Expected a regexp in #{text_value}!" unless regexp

  operator_method.call(source_meta, selector, regexp)
end