lexer

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

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

Variables

View Source
var ActTab = ActionTable{
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: -1,
		Ignore: "!whitespace",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 2,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 2,
		Ignore: "",
	},
}
View Source
var TransTab = TransitionTable{

	func(r rune) int {
		switch {
		case r == 9:
			return 1
		case r == 10:
			return 1
		case r == 13:
			return 1
		case r == 32:
			return 1
		case r == 33:
			return 2
		case r == 34:
			return 3
		case r == 35:
			return 2
		case r == 36:
			return 2
		case r == 37:
			return 2
		case r == 38:
			return 2
		case r == 39:
			return 2
		case r == 42:
			return 2
		case r == 43:
			return 2
		case r == 45:
			return 2
		case r == 47:
			return 2
		case 48 <= r && r <= 57:
			return 2
		case r == 61:
			return 2
		case r == 63:
			return 2
		case 65 <= r && r <= 90:
			return 2
		case r == 94:
			return 2
		case r == 95:
			return 2
		case r == 96:
			return 2
		case 97 <= r && r <= 122:
			return 2
		case r == 123:
			return 2
		case r == 124:
			return 2
		case r == 125:
			return 2
		case r == 126:
			return 2
		case 256 <= r && r <= 1114111:
			return 2
		}
		return NoState
	},

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

	func(r rune) int {
		switch {
		case r == 33:
			return 2
		case r == 35:
			return 2
		case r == 36:
			return 2
		case r == 37:
			return 2
		case r == 38:
			return 2
		case r == 39:
			return 2
		case r == 42:
			return 2
		case r == 43:
			return 2
		case r == 45:
			return 2
		case r == 46:
			return 4
		case r == 47:
			return 2
		case 48 <= r && r <= 57:
			return 2
		case r == 61:
			return 2
		case r == 63:
			return 2
		case r == 64:
			return 5
		case 65 <= r && r <= 90:
			return 2
		case r == 94:
			return 2
		case r == 95:
			return 2
		case r == 96:
			return 2
		case 97 <= r && r <= 122:
			return 2
		case r == 123:
			return 2
		case r == 124:
			return 2
		case r == 125:
			return 2
		case r == 126:
			return 2
		case 256 <= r && r <= 1114111:
			return 2
		}
		return NoState
	},

	func(r rune) int {
		switch {
		case r == 92:
			return 6
		default:
			return 7
		}
	},

	func(r rune) int {
		switch {
		case r == 33:
			return 8
		case r == 35:
			return 8
		case r == 36:
			return 8
		case r == 37:
			return 8
		case r == 38:
			return 8
		case r == 39:
			return 8
		case r == 42:
			return 8
		case r == 43:
			return 8
		case r == 45:
			return 8
		case r == 47:
			return 8
		case 48 <= r && r <= 57:
			return 8
		case r == 61:
			return 8
		case r == 63:
			return 8
		case 65 <= r && r <= 90:
			return 8
		case r == 94:
			return 8
		case r == 95:
			return 8
		case r == 96:
			return 8
		case 97 <= r && r <= 122:
			return 8
		case r == 123:
			return 8
		case r == 124:
			return 8
		case r == 125:
			return 8
		case r == 126:
			return 8
		case 256 <= r && r <= 1114111:
			return 8
		}
		return NoState
	},

	func(r rune) int {
		switch {
		case r == 33:
			return 9
		case r == 35:
			return 9
		case r == 36:
			return 9
		case r == 37:
			return 9
		case r == 38:
			return 9
		case r == 39:
			return 9
		case r == 42:
			return 9
		case r == 43:
			return 9
		case r == 45:
			return 9
		case r == 47:
			return 9
		case 48 <= r && r <= 57:
			return 9
		case r == 61:
			return 9
		case r == 63:
			return 9
		case 65 <= r && r <= 90:
			return 9
		case r == 94:
			return 9
		case r == 95:
			return 9
		case r == 96:
			return 9
		case 97 <= r && r <= 122:
			return 9
		case r == 123:
			return 9
		case r == 124:
			return 9
		case r == 125:
			return 9
		case r == 126:
			return 9
		case 256 <= r && r <= 1114111:
			return 9
		}
		return NoState
	},

	func(r rune) int {
		switch {
		default:
			return 10
		}
	},

	func(r rune) int {
		switch {
		case r == 34:
			return 11
		case r == 92:
			return 12
		default:
			return 7
		}
	},

	func(r rune) int {
		switch {
		case r == 33:
			return 8
		case r == 35:
			return 8
		case r == 36:
			return 8
		case r == 37:
			return 8
		case r == 38:
			return 8
		case r == 39:
			return 8
		case r == 42:
			return 8
		case r == 43:
			return 8
		case r == 45:
			return 8
		case r == 46:
			return 4
		case r == 47:
			return 8
		case 48 <= r && r <= 57:
			return 8
		case r == 61:
			return 8
		case r == 63:
			return 8
		case r == 64:
			return 5
		case 65 <= r && r <= 90:
			return 8
		case r == 94:
			return 8
		case r == 95:
			return 8
		case r == 96:
			return 8
		case 97 <= r && r <= 122:
			return 8
		case r == 123:
			return 8
		case r == 124:
			return 8
		case r == 125:
			return 8
		case r == 126:
			return 8
		case 256 <= r && r <= 1114111:
			return 8
		}
		return NoState
	},

	func(r rune) int {
		switch {
		case r == 33:
			return 9
		case r == 35:
			return 9
		case r == 36:
			return 9
		case r == 37:
			return 9
		case r == 38:
			return 9
		case r == 39:
			return 9
		case r == 42:
			return 9
		case r == 43:
			return 9
		case r == 45:
			return 9
		case r == 46:
			return 13
		case r == 47:
			return 9
		case 48 <= r && r <= 57:
			return 9
		case r == 61:
			return 9
		case r == 63:
			return 9
		case 65 <= r && r <= 90:
			return 9
		case r == 94:
			return 9
		case r == 95:
			return 9
		case r == 96:
			return 9
		case 97 <= r && r <= 122:
			return 9
		case r == 123:
			return 9
		case r == 124:
			return 9
		case r == 125:
			return 9
		case r == 126:
			return 9
		case 256 <= r && r <= 1114111:
			return 9
		}
		return NoState
	},

	func(r rune) int {
		switch {
		case r == 34:
			return 11
		case r == 92:
			return 12
		default:
			return 7
		}
	},

	func(r rune) int {
		switch {
		case r == 64:
			return 5
		}
		return NoState
	},

	func(r rune) int {
		switch {
		default:
			return 10
		}
	},

	func(r rune) int {
		switch {
		case r == 33:
			return 14
		case r == 35:
			return 14
		case r == 36:
			return 14
		case r == 37:
			return 14
		case r == 38:
			return 14
		case r == 39:
			return 14
		case r == 42:
			return 14
		case r == 43:
			return 14
		case r == 45:
			return 14
		case r == 47:
			return 14
		case 48 <= r && r <= 57:
			return 14
		case r == 61:
			return 14
		case r == 63:
			return 14
		case 65 <= r && r <= 90:
			return 14
		case r == 94:
			return 14
		case r == 95:
			return 14
		case r == 96:
			return 14
		case 97 <= r && r <= 122:
			return 14
		case r == 123:
			return 14
		case r == 124:
			return 14
		case r == 125:
			return 14
		case r == 126:
			return 14
		case 256 <= r && r <= 1114111:
			return 14
		}
		return NoState
	},

	func(r rune) int {
		switch {
		case r == 33:
			return 14
		case r == 35:
			return 14
		case r == 36:
			return 14
		case r == 37:
			return 14
		case r == 38:
			return 14
		case r == 39:
			return 14
		case r == 42:
			return 14
		case r == 43:
			return 14
		case r == 45:
			return 14
		case r == 46:
			return 13
		case r == 47:
			return 14
		case 48 <= r && r <= 57:
			return 14
		case r == 61:
			return 14
		case r == 63:
			return 14
		case 65 <= r && r <= 90:
			return 14
		case r == 94:
			return 14
		case r == 95:
			return 14
		case r == 96:
			return 14
		case 97 <= r && r <= 122:
			return 14
		case r == 123:
			return 14
		case r == 124:
			return 14
		case r == 125:
			return 14
		case r == 126:
			return 14
		case 256 <= r && r <= 1114111:
			return 14
		}
		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