lexer

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoState    = -1
	NumStates  = 14
	NumSymbols = 15
)

Variables

View Source
var ActTab = ActionTable{
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: -1,
		Ignore: "!_whitespace",
	},
	ActionRow{
		Accept: 9,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 3,
		Ignore: "",
	},
	ActionRow{
		Accept: 6,
		Ignore: "",
	},
	ActionRow{
		Accept: 4,
		Ignore: "",
	},
	ActionRow{
		Accept: 5,
		Ignore: "",
	},
	ActionRow{
		Accept: 4,
		Ignore: "",
	},
	ActionRow{
		Accept: 8,
		Ignore: "",
	},
	ActionRow{
		Accept: 7,
		Ignore: "",
	},
	ActionRow{
		Accept: 4,
		Ignore: "",
	},
	ActionRow{
		Accept: 8,
		Ignore: "",
	},
	ActionRow{
		Accept: 2,
		Ignore: "",
	},
}
View Source
var TransTab = TransitionTable{

	func(r rune) int {
		switch {
		case r == 32:
			return 1
		case 48 <= r && r <= 57:
			return 2
		case r == 58:
			return 3
		case r == 59:
			return 4
		case r == 61:
			return 5
		case 65 <= r && r <= 90:
			return 6
		case r == 95:
			return 7
		case 97 <= r && r <= 117:
			return 6
		case r == 118:
			return 8
		case 119 <= r && r <= 122:
			return 6
		}
		return NoState
	},

	func(r rune) int {
		switch {
		}
		return NoState
	},

	func(r rune) int {
		switch {
		case r == 46:
			return 9
		case 48 <= r && r <= 57:
			return 2
		}
		return NoState
	},

	func(r rune) int {
		switch {
		case r == 61:
			return 10
		}
		return NoState
	},

	func(r rune) int {
		switch {
		}
		return NoState
	},

	func(r rune) int {
		switch {
		}
		return NoState
	},

	func(r rune) int {
		switch {
		case 65 <= r && r <= 90:
			return 6
		case r == 95:
			return 6
		case 97 <= r && r <= 122:
			return 6
		}
		return NoState
	},

	func(r rune) int {
		switch {
		case 65 <= r && r <= 90:
			return 6
		case r == 95:
			return 6
		case 97 <= r && r <= 122:
			return 6
		}
		return NoState
	},

	func(r rune) int {
		switch {
		case 65 <= r && r <= 90:
			return 6
		case r == 95:
			return 6
		case r == 97:
			return 11
		case 98 <= r && r <= 122:
			return 6
		}
		return NoState
	},

	func(r rune) int {
		switch {
		case 48 <= r && r <= 57:
			return 12
		}
		return NoState
	},

	func(r rune) int {
		switch {
		}
		return NoState
	},

	func(r rune) int {
		switch {
		case 65 <= r && r <= 90:
			return 6
		case r == 95:
			return 6
		case 97 <= r && r <= 113:
			return 6
		case r == 114:
			return 13
		case 115 <= r && r <= 122:
			return 6
		}
		return NoState
	},

	func(r rune) int {
		switch {
		case 48 <= r && r <= 57:
			return 12
		}
		return NoState
	},

	func(r rune) int {
		switch {
		case 65 <= r && r <= 90:
			return 6
		case r == 95:
			return 6
		case 97 <= r && r <= 122:
			return 6
		}
		return NoState
	},
}

Functions

This section is empty.

Types

type ActionRow

type ActionRow struct {
	Accept token.Type
	Ignore string
}

func (ActionRow) String

func (a ActionRow) String() string

type ActionTable

type ActionTable [NumStates]ActionRow

type Lexer

type Lexer struct {
	Context token.Context
	// contains filtered or unexported fields
}

func NewLexer

func NewLexer(src []byte) *Lexer

func NewLexerFile

func NewLexerFile(fpath string) (*Lexer, error)

func (*Lexer) Reset

func (l *Lexer) Reset()

func (*Lexer) Scan

func (l *Lexer) Scan() (tok *token.Token)

type SourceContext

type SourceContext struct {
	Filepath string
}

SourceContext is a simple instance of a token.Context which contains the name of the source file.

func (*SourceContext) Source

func (s *SourceContext) Source() string

type TransitionTable

type TransitionTable [NumStates]func(rune) int

Let s be the current state Let r be the current input rune transitionTable[s](r) returns the next state.

Jump to

Keyboard shortcuts

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