token

package
v0.0.0-...-ef17ad3 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2020 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package token defines constants representing the lexical tokens for pg.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pos

type Pos struct {
	Filename string // filename, if any
	Offset   int    // offset, starting at 0
	Line     int    // line number, starting at 1
	Column   int    // column number, starting at 1 (character count)
}

Pos describes an arbitrary source position including the file, line, and column location. A position is valid if the line number is > 0.

func (Pos) String

func (p Pos) String() string

String returns a string in one of several forms:

file:line:column    valid position with filename
line:column         valid position without filename
file                invalid position with filename
-                   invalid position without filename

type Type

type Type int

Type is the set of lexical tokens of pg.

const (
	ILLEGAL Type = iota
	EOF

	IDENT  // Foo
	STRING // "abc"

	ARROW  // -> or →
	PERIOD // .
	PIPE   // |

	EPSILON // e or ε
)

Token constants

func (Type) IsLiteral

func (t Type) IsLiteral() bool

IsLiteral returns true for tokens corresponding to literals; it returns false otherwise.

func (Type) IsOperator

func (t Type) IsOperator() bool

IsOperator returns true for tokens corresponding to operators and delimiters; it returns false otherwise.

func (Type) String

func (t Type) String() string

String returns the string corresponding to the token.

Jump to

Keyboard shortcuts

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