lexer

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2017 License: Apache-2.0 Imports: 4 Imported by: 6

Documentation

Overview

Package lexer implements the lexer used bye the BadWolf query language. The lexer is loosely written after the parser model described by Rob Pike in his presentation "Lexical Scanning in Go". Slides can be found at http://cuddle.googlecode.com/hg/talk/lex.html#landing-slide.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(input string, capacity int) <-chan Token

New return a new read only channel with the tokens found in the provided input string.

Types

type Token

type Token struct {
	Type         TokenType
	Text         string
	ErrorMessage string
}

Token contains the type and text collected around the captured token.

func (*Token) String added in v0.7.0

func (t *Token) String() string

String returns a readable form of the token.

type TokenType

type TokenType int

TokenType list all the possible tokens returned by a lexer.

const (
	// ItemError contains information about an error triggered while scanning.
	ItemError TokenType = iota
	// ItemEOF indicates end of input to be scanned in BQL.
	ItemEOF
	// ItemQuery represents the select keyword in BQL.
	ItemQuery
	// ItemInsert represents insert keyword in BQL.
	ItemInsert
	// ItemDelete represents insert keyword in BQL.
	ItemDelete
	// ItemCreate represents the creation of a graph in BQL.
	ItemCreate
	// ItemConstruct represents the construct keyword in BQL.
	ItemConstruct
	// ItemDeconstruct represents the deconstruct keyword in BQL.
	ItemDeconstruct
	// ItemDrop represent the destruction of a graph in BQL.
	ItemDrop
	// ItemGraph represent the graph to be created of destroyed in BQL.
	ItemGraph
	// ItemData represents the data keyword in BQL.
	ItemData
	// ItemInto represents the into keyword in BQL.
	ItemInto
	// ItemFrom represents the from keyword in BQL.
	ItemFrom
	// ItemWhere represents the where keyword in BQL.
	ItemWhere
	// ItemAs represents the as keyword in BQL.
	ItemAs
	// ItemType represents keyword type in BQL.
	ItemType
	// ItemID represents id keyword in BQL.
	ItemID
	// ItemAt represents at keyword in BQL.
	ItemAt
	// ItemIn represents in keyword in BQL.
	ItemIn
	// ItemBefore represents the before keyword in BQL.
	ItemBefore
	// ItemAfter represents the after keyword in BQL.
	ItemAfter
	// ItemBetween represents the between keyword in BQL.
	ItemBetween
	// ItemCount represents the count function in BQL.
	ItemCount
	// ItemDistinct represents the distinct modifier in BQL.
	ItemDistinct
	// ItemSum represents the sum function in BQL.
	ItemSum
	// ItemGroup represents the group keyword in group by clause in BQL.
	ItemGroup
	// ItemBy represents the by keyword in group by clause in BQL.
	ItemBy
	// ItemOrder represent the order keyword in group by clause in BQL.
	ItemOrder
	// ItemHaving represents the having clause keyword clause in BQL.
	ItemHaving
	// ItemAsc represents asc keyword on order by clause in BQL.
	ItemAsc
	// ItemDesc represents desc keyword on order by clause in BQL
	ItemDesc
	// ItemLimit represents the limit clause in BQL.
	ItemLimit
	// ItemBinding represents a variable binding in BQL.
	ItemBinding
	// ItemNode represents a BadWolf node in BQL.
	ItemNode
	// ItemBlankNode represents a blank BadWolf node in BQL.
	ItemBlankNode
	// ItemLiteral represents a BadWolf literal in BQL.
	ItemLiteral
	// ItemPredicate represents a BadWolf predicates in BQL.
	ItemPredicate
	// ItemPredicateBound represents a BadWolf predicate bound in BQL.
	ItemPredicateBound
	// ItemLBracket represents the left opening bracket token in BQL.
	ItemLBracket
	// ItemRBracket represents the right opening bracket token in BQL.
	ItemRBracket
	// ItemLPar represents the left opening parenthesis token in BQL.
	ItemLPar
	// ItemRPar represents the right closing parenthesis token in BQL.
	ItemRPar
	// ItemDot represents the graph clause separator . in BQL.
	ItemDot
	// ItemSemicolon represents the final statement semicolon in BQL.
	ItemSemicolon
	// ItemComma represents the graph join operator in BQL.
	ItemComma
	// ItemLT represents < in BQL.
	ItemLT
	// ItemGT represents > in BQL.
	ItemGT
	// ItemEQ represents = in BQL.
	ItemEQ
	// ItemNot represents keyword not in BQL.
	ItemNot
	// ItemAnd represents keyword and in BQL.
	ItemAnd
	// ItemOr represents keyword or in BQL.
	ItemOr
)

func (TokenType) String

func (tt TokenType) String() string

Jump to

Keyboard shortcuts

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