Class: ScopedSearch::QueryLanguage::Compiler
- Inherits:
-
Object
- Object
- ScopedSearch::QueryLanguage::Compiler
- Includes:
- Enumerable, Parser, Tokenizer
- Defined in:
- lib/scoped_search/query_language.rb
Overview
The Compiler class can compile a query string into an Abstract Syntax Tree, which in turn is used to build the SQL query.
This class inclused the Tokenizer module to transform the query stream into a stream of tokens, and includes the Parser module that will transform the stream of tokens into an Abstract Syntax Tree (AST).
Constant Summary
Constant Summary
Constants included from Parser
Parser::ALL_INFIX_OPERATORS, Parser::ALL_PREFIX_OPERATORS, Parser::COMPARISON_OPERATORS, Parser::DEFAULT_SEQUENCE_OPERATOR, Parser::LOGICAL_INFIX_OPERATORS, Parser::LOGICAL_PREFIX_OPERATORS, Parser::NULL_PREFIX_OPERATORS
Constants included from Tokenizer
Tokenizer::KEYWORDS, Tokenizer::OPERATORS
Class Method Summary (collapse)
-
+ (Object) parse(str)
Parser a query string to return an abstract syntax tree.
-
+ (Object) tokenize(str)
Tokenizes a query string to return a stream of tokens.
Instance Method Summary (collapse)
-
- (Compiler) initialize(str)
constructor
:nodoc:.
Methods included from Parser
#parse, #parse_comparison, #parse_expression_sequence, #parse_infix_comparison, #parse_logical_expression, #parse_logical_not_expression, #parse_multiple_values, #parse_null_expression, #parse_prefix_comparison, #parse_value
Methods included from Tokenizer
#current_char, #each_token, #next_char, #peek_char, #tokenize, #tokenize_keyword, #tokenize_operator, #tokenize_quoted_keyword
Constructor Details
- (Compiler) initialize(str)
:nodoc:
19 20 21 |
# File 'lib/scoped_search/query_language.rb', line 19 def initialize(str) # :nodoc: @str = str end |
Class Method Details
+ (Object) parse(str)
Parser a query string to return an abstract syntax tree.
24 25 26 27 |
# File 'lib/scoped_search/query_language.rb', line 24 def self.parse(str) compiler = self.new(str) compiler.parse end |
+ (Object) tokenize(str)
Tokenizes a query string to return a stream of tokens.
30 31 32 33 |
# File 'lib/scoped_search/query_language.rb', line 30 def self.tokenize(str) compiler = self.new(str) compiler.tokenize end |