scan

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: BSD-3-Clause Imports: 7 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Scanner

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

Scanner holds the state of the scanner.

func New

func New(conf config.State, name string, r io.ByteReader) *Scanner

New creates and returns a new scanner.

func (*Scanner) History added in v0.4.0

func (l *Scanner) History() []string

History returns the history as a slice of strings with newlines elided.

func (*Scanner) Next

func (l *Scanner) Next() Token

Next returns the next token.

type Token

type Token struct {
	Type   Type   // The type of this item.
	Line   int    // The line number on which this token appears
	Offset int    // The byte position on the line at start of token
	Text   string // The text of this item.
}

Token represents a token or text string returned from the scanner.

func (Token) String

func (i Token) String() string

type Type

type Type int

Type identifies the type of lex items.

const (
	EOF     Type = iota
	Error        // error occurred; value is text of error
	Newline      // includes spaces and comments leading up to newline.
	// Interesting things
	Assign     // '='
	Char       // printable ASCII character; grab bag for comma etc.
	Identifier // alphanumeric identifier
	LeftBrack  // '['
	LeftParen  // '('
	Number     // number
	Operator   // known operator
	Op         // "op", operator definition keyword
	If         // ":if", loop definition keyword
	Else       // ":else", else definition keyword
	Elif       // ":elif", else-if definition keyword (avoids dangling else)
	While      // ":while", loop definition keyword
	End        // ":end", 'block' end keyword
	Ret        // ":ret", function return keyword
	RightBrack // ']'
	RightParen // ')'
	Semicolon  // ';'
	String     // quoted string (includes quotes)
	Colon      // ':'
)

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