query

package
v0.0.0-...-b09e5ed Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

This is practically copied verbatim from:

https://blog.gopheracademy.com/advent-2014/parsers-lexers/

found after having read:

http://blog.leahhanson.us/post/recursecenter2016/recipeparser.html

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AndEqual

func AndEqual(a1, a2 And) bool

func ExprEqual

func ExprEqual(e1, e2 Expr) bool

Types

type And

type And struct {
	Tests []Test
}

type Datum

type Datum struct {
	Type Token  // STRING, IDENT, TRUE, FALSE, NUMBER
	Lit  string // true, false
}

type Expr

type Expr struct {
	Ands []And
}

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

func NewParser

func NewParser(r io.Reader) *Parser

func (*Parser) Parse

func (p *Parser) Parse() (*Expr, error)

func (*Parser) ParseConjuction

func (p *Parser) ParseConjuction() (And, error)

func (*Parser) ParseDatum

func (p *Parser) ParseDatum() (Datum, error)

func (*Parser) ParseOperator

func (p *Parser) ParseOperator() (tok Token, err error)

func (*Parser) ParseTest

func (p *Parser) ParseTest() (Test, error)

type Scanner

type Scanner struct {
	// contains filtered or unexported fields
}

func NewScanner

func NewScanner(r io.Reader) *Scanner

func (*Scanner) Scan

func (s *Scanner) Scan() (tok Token, lit string)

type Test

type Test struct {
	Lhs Datum
	Op  Token // IN, EQUALS
	Rhs Datum
}

type Token

type Token int
const (
	ILLEGAL Token = iota
	EOF
	WS

	IDENT
	STRING
	TRUE
	FALSE

	EQUALS
	IN       // list contains equal item
	CONTAINS // text contains substring

	// Keywords
	AND
	OR
	NOT
)

Jump to

Keyboard shortcuts

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