scanner

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Scanner

type Scanner struct {
	Input     string
	Start     int
	Pos       int
	RuneWidth int
	LastWidth int
}

func (*Scanner) Emit

func (s *Scanner) Emit() parse.Token

Emit the next Token found on Scanner.Input

func (*Scanner) MatchFloat

func (s *Scanner) MatchFloat() int

MatchFloat returns the length of the next token, assuming it is a floating point number

Grammar:

float           = *DIGIT "." 1*DIGIT

func (*Scanner) MatchIdentifier

func (s *Scanner) MatchIdentifier() int

MatchIdentifier returns the length of the next token, assuming it is an identifier.

Grammar:

identifier      = 1*(ALPHA / DIGIT / '_' / '-')

func (*Scanner) MatchInteger

func (s *Scanner) MatchInteger() int

MatchInteger returns the length of the next token, assuming it is a number

Grammar:

integer          = 1*DIGIT

func (*Scanner) MatchString

func (s *Scanner) MatchString() int

MatchString returns the length of the next token, assuming it is a string

Grammar:

string          = DQUOTE *ALPHANUM DQUOTE / SQUOTE *ALPHANUM SQUOTE

func (*Scanner) MatchTimeWhence

func (s *Scanner) MatchTimeWhence() int

MatchTimeWhence returns the length of the next token, assuming it is a time-whence

Grammar:

time-whence     = "~now" / "~" RFC3339

func (*Scanner) MatchTimespan

func (s *Scanner) MatchTimespan() int

MatchTimespan returns the length of the next token, assuming it is a timespan

Grammar:

timespan        = "@second" / "@minute" / "@hour" / "@day" / "@week" / "@month" / "@year"

func (*Scanner) MatchTopic

func (s *Scanner) MatchTopic() int

MatchTopic returns the length of the next token, assuming it is a topic string.

Grammar:

topic           = "/" 1*(ALPHA / DIGIT / "/")

func (*Scanner) Rewind

func (s *Scanner) Rewind()

Rewind the last read token

func (*Scanner) SkipToBoundary

func (s *Scanner) SkipToBoundary(boundary boundaryFunc) int

SkipToBoundary returns the number of bytes until the next delimiter. This is useful for skipping over invalid tokens.

type TokenType

type TokenType int
const (
	TOK_INVALID TokenType = iota
	TOK_EOF
	TOK_NL

	TOK_IDENTIFIER
	TOK_KEYWORD
	TOK_INTEGER
	TOK_FLOAT
	TOK_STRING
	TOK_TOPIC
	TOK_COMMA
	TOK_COLON
	TOK_PIPE

	// Expressions
	TOK_EQ_EQ
	TOK_NOT_EQ
	TOK_LESS
	TOK_LESS_EQ
	TOK_GREATER
	TOK_GREATER_EQ
	TOK_PLUS
	TOK_MINUS
	TOK_SLASH
	TOK_STAR

	// Time
	TOK_WHENCE
	TOK_TIMESPAN

	TOK_PAREN_L
	TOK_PAREN_R
	TOK_BRACKET_L
	TOK_BRACKET_R

	TOK_ARROW
)

func (TokenType) ToString

func (t TokenType) ToString() string

Jump to

Keyboard shortcuts

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