token

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package token declares a number of constants that represent lexical tokens in spok as well as basic operations on those tokens e.g. printing

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Token

type Token struct {
	Value string // Value, e.g. "("
	Type  Type   // Type, e.g. LPAREN
	Pos   int    // Starting position of this token in the input string
	Line  int    // Line number at the start of this token
}

Token represents a spok lexical token.

func (Token) Is

func (t Token) Is(typ Type) bool

Is returns whether or not the current token is of a certain type.

func (Token) String

func (t Token) String() string

String satisfies the stringer interface and allows us to pretty print the tokens.

type Type

type Type int

Type is the set of lexical tokens in spok.

const (
	EOF     Type = iota // EOF
	ERROR               // ERROR
	COMMENT             // COMMENT
	HASH                // #
	LPAREN              // (
	RPAREN              // )
	LBRACE              // {
	RBRACE              // }
	QUOTE               // "
	COMMA               // ,
	TASK                // task
	STRING              // STRING
	COMMAND             // COMMAND
	OUTPUT              // ->
	IDENT               // IDENT
	DECLARE             // :=
	LINTERP             // {{
	RINTERP             // }}
)

Note: EOF is the zero value such that when the parser reads from a closed channel the read value will be token.EOF.

func (Type) String

func (i Type) String() string

Jump to

Keyboard shortcuts

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