lexer

package
v0.0.0-...-492a895 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 26, 2019 License: MIT Imports: 6 Imported by: 3

Documentation

Overview

Package lexer build a query tree from the search strategy.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PreProcess

func PreProcess(query string, options LexOptions) string

PreProcess attempts to remove the starting numbers from a query and will trim each line in a query if there are any additional, unnecessary spaces. The output should be a fairly clean search strategy.

func ProcessInfixOperators

func ProcessInfixOperators(queries map[int]string, operators string) (map[string]map[int]string, error)

ProcessInfixOperators replaces the references in an infix query with the actual query string.

func ProcessNamedOperators

func ProcessNamedOperators(queries map[int]string, operator string) (map[string]map[int]string, error)

ProcessNamedOperators replaces the references in a prefix query with the actual query string.

func ProcessPrefixOperators

func ProcessPrefixOperators(queries map[int]string, operator string) (map[string]map[int]string, error)

ProcessInfixOperators replaces the references in a prefix query with the actual query string.

Types

type LexOptions

type LexOptions struct {
	FormatParenthesis bool
}

LexOptions allows for configuration of how the query string is lexed.

type Node

type Node struct {
	Value     string
	Reference int
	Operator  string
	Children  []Node
}

Node contains the encoding of the query as a tree.

func ExpandQuery

func ExpandQuery(query map[int]map[string]map[int]string) (Node, error)

ExpandQuery takes a query that has been processed and expands it into a tree.

func Lex

func Lex(query string, options LexOptions) (Node, error)

Lex creates the abstract syntax tree for the query. It will preprocess the query to try to normalise it. This function only creates the tree; it does not attempt to parse the individual lines in the query.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL