lexer

package
Version: v0.5.8 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2019 License: BSD-3-Clause Imports: 4 Imported by: 1

Documentation

Index

Constants

View Source
const (
	NoState    = -1
	NumStates  = 75
	NumSymbols = 80
)

Variables

View Source
var ActTab = ActionTable{
	ActionRow{
		Accept: 17,
		Ignore: "",
	},
	ActionRow{
		Accept: -1,
		Ignore: "!whitespace",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 16,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 4,
		Ignore: "",
	},
	ActionRow{
		Accept: 5,
		Ignore: "",
	},
	ActionRow{
		Accept: 14,
		Ignore: "",
	},
	ActionRow{
		Accept: 12,
		Ignore: "",
	},
	ActionRow{
		Accept: 19,
		Ignore: "",
	},
	ActionRow{
		Accept: 13,
		Ignore: "",
	},
	ActionRow{
		Accept: 17,
		Ignore: "",
	},
	ActionRow{
		Accept: 15,
		Ignore: "",
	},
	ActionRow{
		Accept: 24,
		Ignore: "",
	},
	ActionRow{
		Accept: 21,
		Ignore: "",
	},
	ActionRow{
		Accept: 8,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 10,
		Ignore: "",
	},
	ActionRow{
		Accept: 20,
		Ignore: "",
	},
	ActionRow{
		Accept: 17,
		Ignore: "",
	},
	ActionRow{
		Accept: 17,
		Ignore: "",
	},
	ActionRow{
		Accept: 17,
		Ignore: "",
	},
	ActionRow{
		Accept: 17,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 7,
		Ignore: "",
	},
	ActionRow{
		Accept: 22,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 25,
		Ignore: "",
	},
	ActionRow{
		Accept: 25,
		Ignore: "",
	},
	ActionRow{
		Accept: 3,
		Ignore: "",
	},
	ActionRow{
		Accept: 23,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 18,
		Ignore: "",
	},
	ActionRow{
		Accept: 28,
		Ignore: "",
	},
	ActionRow{
		Accept: 17,
		Ignore: "",
	},
	ActionRow{
		Accept: 17,
		Ignore: "",
	},
	ActionRow{
		Accept: 17,
		Ignore: "",
	},
	ActionRow{
		Accept: 9,
		Ignore: "",
	},
	ActionRow{
		Accept: 6,
		Ignore: "",
	},
	ActionRow{
		Accept: 11,
		Ignore: "",
	},
	ActionRow{
		Accept: 17,
		Ignore: "",
	},
	ActionRow{
		Accept: 17,
		Ignore: "",
	},
	ActionRow{
		Accept: 17,
		Ignore: "",
	},
	ActionRow{
		Accept: 17,
		Ignore: "",
	},
	ActionRow{
		Accept: 2,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 25,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 28,
		Ignore: "",
	},
	ActionRow{
		Accept: 28,
		Ignore: "",
	},
	ActionRow{
		Accept: 17,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 28,
		Ignore: "",
	},
	ActionRow{
		Accept: 17,
		Ignore: "",
	},
	ActionRow{
		Accept: 29,
		Ignore: "",
	},
	ActionRow{
		Accept: 17,
		Ignore: "",
	},
	ActionRow{
		Accept: 17,
		Ignore: "",
	},
	ActionRow{
		Accept: 28,
		Ignore: "",
	},
	ActionRow{
		Accept: 17,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 28,
		Ignore: "",
	},
	ActionRow{
		Accept: 28,
		Ignore: "",
	},
	ActionRow{
		Accept: 17,
		Ignore: "",
	},
	ActionRow{
		Accept: 30,
		Ignore: "",
	},
	ActionRow{
		Accept: 26,
		Ignore: "",
	},
	ActionRow{
		Accept: 0,
		Ignore: "",
	},
	ActionRow{
		Accept: 28,
		Ignore: "",
	},
	ActionRow{
		Accept: 28,
		Ignore: "",
	},
	ActionRow{
		Accept: 27,
		Ignore: "",
	},
	ActionRow{
		Accept: 28,
		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 == 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 48 <= r && r <= 57:
			return 16
		case r == 58:
			return 17
		case r == 60:
			return 18
		case r == 61:
			return 19
		case r == 62:
			return 20
		case r == 63:
			return 21
		case 65 <= r && r <= 90:
			return 22
		case r == 95:
			return 22
		case 97 <= r && r <= 101:
			return 22
		case r == 102:
			return 23
		case 103 <= r && r <= 109:
			return 22
		case r == 110:
			return 24
		case 111 <= r && r <= 115:
			return 22
		case r == 116:
			return 25
		case 117 <= r && r <= 122:
			return 22
		case r == 124:
			return 26
		}
		return NoState
	},

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

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

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

	func(r rune) int {
		switch {
		case r == 32:
			return 30
		case r == 36:
			return 30
		case r == 45:
			return 30
		case r == 46:
			return 30
		case 48 <= r && r <= 57:
			return 30
		case 65 <= r && r <= 90:
			return 30
		case r == 91:
			return 31
		case r == 93:
			return 30
		case r == 95:
			return 30
		case 97 <= r && r <= 122:
			return 30
		case r == 123:
			return 30
		case r == 125:
			return 30
		}
		return NoState
	},

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

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

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

	func(r rune) int {
		switch {
		case r == 41:
			return 35
		}
		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 r == 46:
			return 22
		case 48 <= r && r <= 57:
			return 36
		case 65 <= r && r <= 68:
			return 22
		case r == 69:
			return 37
		case 70 <= r && r <= 90:
			return 22
		case r == 95:
			return 22
		case 97 <= r && r <= 100:
			return 22
		case r == 101:
			return 37
		case 102 <= r && r <= 122:
			return 22
		}
		return NoState
	},

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

	func(r rune) int {
		switch {
		case r == 46:
			return 38
		case 48 <= r && r <= 57:
			return 16
		case 65 <= r && r <= 68:
			return 22
		case r == 69:
			return 39
		case 70 <= r && r <= 90:
			return 22
		case r == 95:
			return 22
		case 97 <= r && r <= 100:
			return 22
		case r == 101:
			return 39
		case 102 <= r && r <= 122:
			return 22
		}
		return NoState
	},

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

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

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

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

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

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

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

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

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

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

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

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

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

	func(r rune) int {
		switch {
		case r == 32:
			return 30
		case r == 36:
			return 30
		case r == 45:
			return 30
		case r == 46:
			return 30
		case 48 <= r && r <= 57:
			return 30
		case 65 <= r && r <= 90:
			return 30
		case r == 91:
			return 31
		case r == 93:
			return 30
		case r == 95:
			return 30
		case 97 <= r && r <= 122:
			return 30
		case r == 123:
			return 30
		case r == 125:
			return 30
		}
		return NoState
	},

	func(r rune) int {
		switch {
		case r == 93:
			return 49
		default:
			return 50
		}
	},

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

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

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

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

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

	func(r rune) int {
		switch {
		case r == 43:
			return 52
		case r == 45:
			return 52
		case r == 46:
			return 22
		case 48 <= r && r <= 57:
			return 53
		case 65 <= r && r <= 90:
			return 22
		case r == 95:
			return 22
		case 97 <= r && r <= 122:
			return 22
		}
		return NoState
	},

	func(r rune) int {
		switch {
		case r == 46:
			return 22
		case 48 <= r && r <= 57:
			return 54
		case 65 <= r && r <= 68:
			return 22
		case r == 69:
			return 55
		case 70 <= r && r <= 90:
			return 22
		case r == 95:
			return 22
		case 97 <= r && r <= 100:
			return 22
		case r == 101:
			return 55
		case 102 <= r && r <= 122:
			return 22
		}
		return NoState
	},

	func(r rune) int {
		switch {
		case r == 43:
			return 56
		case r == 45:
			return 56
		case r == 46:
			return 22
		case 48 <= r && r <= 57:
			return 57
		case 65 <= r && r <= 90:
			return 22
		case r == 95:
			return 22
		case 97 <= r && r <= 122:
			return 22
		}
		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 22
		case 48 <= r && r <= 57:
			return 22
		case 65 <= r && r <= 90:
			return 22
		case r == 95:
			return 22
		case 97 <= r && r <= 107:
			return 22
		case r == 108:
			return 58
		case 109 <= r && r <= 122:
			return 22
		}
		return NoState
	},

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

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

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

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

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

	func(r rune) int {
		switch {
		case r == 32:
			return 30
		case r == 36:
			return 30
		case r == 45:
			return 30
		case r == 46:
			return 30
		case 48 <= r && r <= 57:
			return 30
		case 65 <= r && r <= 90:
			return 30
		case r == 91:
			return 31
		case r == 93:
			return 30
		case r == 95:
			return 30
		case 97 <= r && r <= 122:
			return 30
		case r == 123:
			return 30
		case r == 125:
			return 30
		}
		return NoState
	},

	func(r rune) int {
		switch {
		case r == 93:
			return 49
		default:
			return 50
		}
	},

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

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

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

	func(r rune) int {
		switch {
		case r == 46:
			return 22
		case 48 <= r && r <= 57:
			return 54
		case 65 <= r && r <= 68:
			return 22
		case r == 69:
			return 63
		case 70 <= r && r <= 90:
			return 22
		case r == 95:
			return 22
		case 97 <= r && r <= 100:
			return 22
		case r == 101:
			return 63
		case 102 <= r && r <= 122:
			return 22
		}
		return NoState
	},

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

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

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

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

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

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

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

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

	func(r rune) int {
		switch {
		case r == 43:
			return 70
		case r == 45:
			return 70
		case r == 46:
			return 22
		case 48 <= r && r <= 57:
			return 71
		case 65 <= r && r <= 90:
			return 22
		case r == 95:
			return 22
		case 97 <= r && r <= 122:
			return 22
		}
		return NoState
	},

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

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

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

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

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

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

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

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

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

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

	func(r rune) int {
		switch {
		case 48 <= r && r <= 57:
			return 74
		}
		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