lexer

package
v0.9.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: May 3, 2019 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoState    = -1
	NumStates  = 77
	NumSymbols = 82
)

Variables

View Source
var ActTab = ActionTable{
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: -1,
		Ignore: "!whitespace",
	},
	ActionRow{
		Accept: 15,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 29,
		Ignore: "",
	},
	ActionRow{
		Accept: 14,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 17,
		Ignore: "",
	},
	ActionRow{
		Accept: 18,
		Ignore: "",
	},
	ActionRow{
		Accept: 12,
		Ignore: "",
	},
	ActionRow{
		Accept: 10,
		Ignore: "",
	},
	ActionRow{
		Accept: 34,
		Ignore: "",
	},
	ActionRow{
		Accept: 11,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 13,
		Ignore: "",
	},
	ActionRow{
		Accept: 26,
		Ignore: "",
	},
	ActionRow{
		Accept: 26,
		Ignore: "",
	},
	ActionRow{
		Accept: 21,
		Ignore: "",
	},
	ActionRow{
		Accept: 6,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 8,
		Ignore: "",
	},
	ActionRow{
		Accept: 20,
		Ignore: "",
	},
	ActionRow{
		Accept: 16,
		Ignore: "",
	},
	ActionRow{
		Accept: 31,
		Ignore: "",
	},
	ActionRow{
		Accept: 32,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 16,
		Ignore: "",
	},
	ActionRow{
		Accept: 16,
		Ignore: "",
	},
	ActionRow{
		Accept: 16,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 5,
		Ignore: "",
	},
	ActionRow{
		Accept: 28,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 29,
		Ignore: "",
	},
	ActionRow{
		Accept: 3,
		Ignore: "",
	},
	ActionRow{
		Accept: 28,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 27,
		Ignore: "",
	},
	ActionRow{
		Accept: 30,
		Ignore: "",
	},
	ActionRow{
		Accept: 27,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 7,
		Ignore: "",
	},
	ActionRow{
		Accept: 4,
		Ignore: "",
	},
	ActionRow{
		Accept: 9,
		Ignore: "",
	},
	ActionRow{
		Accept: 19,
		Ignore: "",
	},
	ActionRow{
		Accept: 16,
		Ignore: "",
	},
	ActionRow{
		Accept: 28,
		Ignore: "",
	},
	ActionRow{
		Accept: 16,
		Ignore: "",
	},
	ActionRow{
		Accept: 16,
		Ignore: "",
	},
	ActionRow{
		Accept: 16,
		Ignore: "",
	},
	ActionRow{
		Accept: 16,
		Ignore: "",
	},
	ActionRow{
		Accept: 2,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 29,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 30,
		Ignore: "",
	},
	ActionRow{
		Accept: 27,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 27,
		Ignore: "",
	},
	ActionRow{
		Accept: 19,
		Ignore: "",
	},
	ActionRow{
		Accept: 16,
		Ignore: "",
	},
	ActionRow{
		Accept: 24,
		Ignore: "",
	},
	ActionRow{
		Accept: 16,
		Ignore: "",
	},
	ActionRow{
		Accept: 16,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 27,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 27,
		Ignore: "",
	},
	ActionRow{
		Accept: 19,
		Ignore: "",
	},
	ActionRow{
		Accept: 16,
		Ignore: "",
	},
	ActionRow{
		Accept: 25,
		Ignore: "",
	},
	ActionRow{
		Accept: 22,
		Ignore: "",
	},
	ActionRow{
		Accept: 23,
		Ignore: "",
	},
}
View Source
var TransTab = TransitionTable{

	func(r rune) int {
		switch {
		case r == 9:
			return 1
		case r == 10:
			return 1
		case r == 11:
			return 1
		case r == 12:
			return 1
		case r == 13:
			return 1
		case r == 32:
			return 1
		case r == 33:
			return 2
		case r == 34:
			return 3
		case r == 36:
			return 4
		case r == 37:
			return 5
		case r == 38:
			return 6
		case r == 39:
			return 7
		case r == 40:
			return 8
		case r == 41:
			return 9
		case r == 42:
			return 10
		case r == 43:
			return 11
		case r == 44:
			return 12
		case r == 45:
			return 13
		case r == 46:
			return 14
		case r == 47:
			return 15
		case r == 48:
			return 16
		case 49 <= r && r <= 57:
			return 17
		case r == 58:
			return 18
		case r == 60:
			return 19
		case r == 61:
			return 20
		case r == 62:
			return 21
		case r == 63:
			return 22
		case 65 <= r && r <= 90:
			return 23
		case r == 91:
			return 24
		case r == 93:
			return 25
		case r == 95:
			return 23
		case r == 96:
			return 26
		case 97 <= r && r <= 101:
			return 23
		case r == 102:
			return 27
		case 103 <= r && r <= 109:
			return 23
		case r == 110:
			return 28
		case 111 <= r && r <= 115:
			return 23
		case r == 116:
			return 29
		case 117 <= r && r <= 122:
			return 23
		case r == 124:
			return 30
		}
		return NoState
	},

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

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

	func(r rune) int {
		switch {
		case r == 34:
			return 32
		case r == 92:
			return 33
		default:
			return 3
		}
	},

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

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

	func(r rune) int {
		switch {
		case r == 38:
			return 35
		}
		return NoState
	},

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

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

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

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

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

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

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

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

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

	func(r rune) int {
		switch {
		case r == 46:
			return 40
		case 48 <= r && r <= 57:
			return 41
		case r == 69:
			return 42
		case r == 101:
			return 42
		}
		return NoState
	},

	func(r rune) int {
		switch {
		case r == 46:
			return 40
		case 48 <= r && r <= 57:
			return 17
		case r == 69:
			return 42
		case r == 101:
			return 42
		}
		return NoState
	},

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

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

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

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

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

	func(r rune) int {
		switch {
		case r == 46:
			return 46
		case 48 <= r && r <= 57:
			return 47
		case 65 <= r && r <= 90:
			return 23
		case r == 95:
			return 23
		case 97 <= r && r <= 122:
			return 23
		}
		return NoState
	},

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

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

	func(r rune) int {
		switch {
		case r == 96:
			return 48
		default:
			return 26
		}
	},

	func(r rune) int {
		switch {
		case r == 46:
			return 46
		case 48 <= r && r <= 57:
			return 47
		case 65 <= r && r <= 90:
			return 23
		case r == 95:
			return 23
		case r == 97:
			return 49
		case 98 <= r && r <= 122:
			return 23
		}
		return NoState
	},

	func(r rune) int {
		switch {
		case r == 46:
			return 46
		case 48 <= r && r <= 57:
			return 47
		case 65 <= r && r <= 90:
			return 23
		case r == 95:
			return 23
		case 97 <= r && r <= 104:
			return 23
		case r == 105:
			return 50
		case 106 <= r && r <= 116:
			return 23
		case r == 117:
			return 51
		case 118 <= r && r <= 122:
			return 23
		}
		return NoState
	},

	func(r rune) int {
		switch {
		case r == 46:
			return 46
		case 48 <= r && r <= 57:
			return 47
		case 65 <= r && r <= 90:
			return 23
		case r == 95:
			return 23
		case 97 <= r && r <= 113:
			return 23
		case r == 114:
			return 52
		case 115 <= r && r <= 122:
			return 23
		}
		return NoState
	},

	func(r rune) int {
		switch {
		case r == 124:
			return 53
		}
		return NoState
	},

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

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

	func(r rune) int {
		switch {
		case r == 34:
			return 3
		case r == 110:
			return 54
		case r == 114:
			return 54
		case r == 116:
			return 54
		}
		return NoState
	},

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

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

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

	func(r rune) int {
		switch {
		case r == 39:
			return 7
		case r == 110:
			return 56
		case r == 114:
			return 56
		case r == 116:
			return 56
		}
		return NoState
	},

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

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

	func(r rune) int {
		switch {
		case 48 <= r && r <= 57:
			return 59
		case r == 69:
			return 60
		case r == 101:
			return 60
		}
		return NoState
	},

	func(r rune) int {
		switch {
		case r == 46:
			return 40
		case 48 <= r && r <= 57:
			return 41
		case r == 69:
			return 42
		case r == 101:
			return 42
		}
		return NoState
	},

	func(r rune) int {
		switch {
		case r == 43:
			return 61
		case r == 45:
			return 61
		case 48 <= r && r <= 57:
			return 62
		}
		return NoState
	},

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

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

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

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

	func(r rune) int {
		switch {
		case r == 46:
			return 46
		case 48 <= r && r <= 57:
			return 47
		case 65 <= r && r <= 90:
			return 23
		case r == 95:
			return 23
		case 97 <= r && r <= 122:
			return 23
		}
		return NoState
	},

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

	func(r rune) int {
		switch {
		case r == 46:
			return 46
		case 48 <= r && r <= 57:
			return 47
		case 65 <= r && r <= 90:
			return 23
		case r == 95:
			return 23
		case 97 <= r && r <= 107:
			return 23
		case r == 108:
			return 64
		case 109 <= r && r <= 122:
			return 23
		}
		return NoState
	},

	func(r rune) int {
		switch {
		case r == 46:
			return 46
		case 48 <= r && r <= 57:
			return 47
		case 65 <= r && r <= 90:
			return 23
		case r == 95:
			return 23
		case 97 <= r && r <= 107:
			return 23
		case r == 108:
			return 65
		case 109 <= r && r <= 122:
			return 23
		}
		return NoState
	},

	func(r rune) int {
		switch {
		case r == 46:
			return 46
		case 48 <= r && r <= 57:
			return 47
		case 65 <= r && r <= 90:
			return 23
		case r == 95:
			return 23
		case 97 <= r && r <= 107:
			return 23
		case r == 108:
			return 66
		case 109 <= r && r <= 122:
			return 23
		}
		return NoState
	},

	func(r rune) int {
		switch {
		case r == 46:
			return 46
		case 48 <= r && r <= 57:
			return 47
		case 65 <= r && r <= 90:
			return 23
		case r == 95:
			return 23
		case 97 <= r && r <= 116:
			return 23
		case r == 117:
			return 67
		case 118 <= r && r <= 122:
			return 23
		}
		return NoState
	},

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

	func(r rune) int {
		switch {
		case r == 34:
			return 32
		case r == 92:
			return 33
		default:
			return 3
		}
	},

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

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

	func(r rune) int {
		switch {
		case r == 43:
			return 68
		case r == 45:
			return 68
		case 48 <= r && r <= 57:
			return 69
		}
		return NoState
	},

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

	func(r rune) int {
		switch {
		case 48 <= r && r <= 57:
			return 59
		case r == 69:
			return 60
		case r == 101:
			return 60
		}
		return NoState
	},

	func(r rune) int {
		switch {
		case r == 43:
			return 70
		case r == 45:
			return 70
		case 48 <= r && r <= 57:
			return 71
		}
		return NoState
	},

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

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

	func(r rune) int {
		switch {
		case r == 46:
			return 46
		case 48 <= r && r <= 57:
			return 72
		case 65 <= r && r <= 90:
			return 63
		case r == 95:
			return 63
		case 97 <= r && r <= 122:
			return 63
		}
		return NoState
	},

	func(r rune) int {
		switch {
		case r == 46:
			return 46
		case 48 <= r && r <= 57:
			return 47
		case 65 <= r && r <= 90:
			return 23
		case r == 95:
			return 23
		case 97 <= r && r <= 114:
			return 23
		case r == 115:
			return 73
		case 116 <= r && r <= 122:
			return 23
		}
		return NoState
	},

	func(r rune) int {
		switch {
		case r == 46:
			return 46
		case 48 <= r && r <= 57:
			return 47
		case 65 <= r && r <= 90:
			return 23
		case r == 95:
			return 23
		case 97 <= r && r <= 122:
			return 23
		}
		return NoState
	},

	func(r rune) int {
		switch {
		case r == 46:
			return 46
		case 48 <= r && r <= 57:
			return 47
		case 65 <= r && r <= 90:
			return 23
		case r == 95:
			return 23
		case 97 <= r && r <= 107:
			return 23
		case r == 108:
			return 74
		case 109 <= r && r <= 122:
			return 23
		}
		return NoState
	},

	func(r rune) int {
		switch {
		case r == 46:
			return 46
		case 48 <= r && r <= 57:
			return 47
		case 65 <= r && r <= 90:
			return 23
		case r == 95:
			return 23
		case 97 <= r && r <= 100:
			return 23
		case r == 101:
			return 75
		case 102 <= r && r <= 122:
			return 23
		}
		return NoState
	},

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

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

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

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

	func(r rune) int {
		switch {
		case r == 46:
			return 46
		case 48 <= r && r <= 57:
			return 72
		case 65 <= r && r <= 90:
			return 63
		case r == 95:
			return 63
		case 97 <= r && r <= 122:
			return 63
		}
		return NoState
	},

	func(r rune) int {
		switch {
		case r == 46:
			return 46
		case 48 <= r && r <= 57:
			return 47
		case 65 <= r && r <= 90:
			return 23
		case r == 95:
			return 23
		case 97 <= r && r <= 100:
			return 23
		case r == 101:
			return 76
		case 102 <= r && r <= 122:
			return 23
		}
		return NoState
	},

	func(r rune) int {
		switch {
		case r == 46:
			return 46
		case 48 <= r && r <= 57:
			return 47
		case 65 <= r && r <= 90:
			return 23
		case r == 95:
			return 23
		case 97 <= r && r <= 122:
			return 23
		}
		return NoState
	},

	func(r rune) int {
		switch {
		case r == 46:
			return 46
		case 48 <= r && r <= 57:
			return 47
		case 65 <= r && r <= 90:
			return 23
		case r == 95:
			return 23
		case 97 <= r && r <= 122:
			return 23
		}
		return NoState
	},

	func(r rune) int {
		switch {
		case r == 46:
			return 46
		case 48 <= r && r <= 57:
			return 47
		case 65 <= r && r <= 90:
			return 23
		case r == 95:
			return 23
		case 97 <= r && r <= 122:
			return 23
		}
		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 {
	// 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 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