class SyntaxTree::Database::Pattern

A pattern matching expression that will be compiled into a query.

Attributes

query[R]

Public Class Methods

new(query) click to toggle source
# File lib/syntax_tree/database.rb, line 172
def initialize(query)
  @query = query
end

Public Instance Methods

compile() click to toggle source
# File lib/syntax_tree/database.rb, line 176
def compile
  program =
    begin
      SyntaxTree.parse("case nil\nin #{query}\nend")
    rescue Parser::ParseError
      raise CompilationError, query
    end

  compile_node(program.statements.body.first.consequent.pattern)
end