aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/homemade/scl/token.go
blob: 77d5ab266991ebbb1cb76e00ca936b926f695a4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package scl

//go:generate stringer -type=tokenKind -output=token_string.go
type tokenKind int

const (
	tokenLineComment tokenKind = iota
	tokenMixinDeclaration
	tokenVariable
	tokenVariableAssignment
	tokenFunctionCall
	tokenLiteral
	tokenVariableDeclaration
	tokenConditionalVariableAssignment
	tokenCommentStart
	tokenCommentEnd
)

var tokenKindsByString = map[tokenKind]string{
	tokenLineComment:                   "line comment",
	tokenMixinDeclaration:              "mixin declaration",
	tokenVariableAssignment:            "variable assignment",
	tokenVariableDeclaration:           "variable declaration",
	tokenConditionalVariableAssignment: "conditional variable declaration",
	tokenFunctionCall:                  "function call",
	tokenLiteral:                       "literal",
	tokenCommentStart:                  "comment start",
	tokenCommentEnd:                    "comment end",
}

type token struct {
	kind    tokenKind
	content string
	line    *scannerLine
}

func (t token) String() string {
	return tokenKindsByString[t.kind]
}