zclsyntax: use stringer for TokenType stringification
This commit is contained in:
parent
63fcfd6b7d
commit
b8db08bf04
@ -1,6 +1,8 @@
|
||||
package zclsyntax
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/apparentlymart/go-textseg/textseg"
|
||||
"github.com/zclconf/go-zcl/zcl"
|
||||
)
|
||||
@ -16,6 +18,8 @@ type Token struct {
|
||||
// TokenType is an enumeration used for the Type field on Token.
|
||||
type TokenType rune
|
||||
|
||||
//go:generate stringer -type TokenType -output token_type_string.go
|
||||
|
||||
const (
|
||||
// Single-character tokens are represented by their own character, for
|
||||
// convenience in producing these within the scanner. However, the values
|
||||
@ -80,6 +84,10 @@ const (
|
||||
TokenBadUTF8 TokenType = '💩'
|
||||
)
|
||||
|
||||
func (t TokenType) GoString() string {
|
||||
return fmt.Sprintf("zclsyntax.%s", t.String())
|
||||
}
|
||||
|
||||
type tokenAccum struct {
|
||||
Filename string
|
||||
Bytes []byte
|
||||
|
60
zcl/zclsyntax/token_type_string.go
Normal file
60
zcl/zclsyntax/token_type_string.go
Normal file
@ -0,0 +1,60 @@
|
||||
// Code generated by "stringer -type TokenType -output token_type_string.go"; DO NOT EDIT.
|
||||
|
||||
package zclsyntax
|
||||
|
||||
import "fmt"
|
||||
|
||||
const _TokenType_name = "TokenNewlineTokenBangTokenBitwiseAndTokenOParenTokenCParenTokenStarTokenPlusTokenMinusTokenDotTokenSlashTokenColonTokenSemicolonTokenLessThanTokenEqualTokenGreaterThanTokenQuestionTokenHeredocTokenIdentTokenNumberLitTokenStringLitTokenOBrackTokenCBrackTokenBitwiseXorTokenBacktickTokenOBraceTokenBitwiseOrTokenCBraceTokenBitwiseNotTokenOQuoteTokenCQuoteTokenTemplateControlTokenTemplateSeqEndTokenAndTokenOrTokenTemplateInterpTokenNotEqualTokenLessThanEqTokenGreaterThanEqTokenEOFTokenTabTokenStarStarTokenInvalidTokenBadUTF8"
|
||||
|
||||
var _TokenType_map = map[TokenType]string{
|
||||
10: _TokenType_name[0:12],
|
||||
33: _TokenType_name[12:21],
|
||||
38: _TokenType_name[21:36],
|
||||
40: _TokenType_name[36:47],
|
||||
41: _TokenType_name[47:58],
|
||||
42: _TokenType_name[58:67],
|
||||
43: _TokenType_name[67:76],
|
||||
45: _TokenType_name[76:86],
|
||||
46: _TokenType_name[86:94],
|
||||
47: _TokenType_name[94:104],
|
||||
58: _TokenType_name[104:114],
|
||||
59: _TokenType_name[114:128],
|
||||
60: _TokenType_name[128:141],
|
||||
61: _TokenType_name[141:151],
|
||||
62: _TokenType_name[151:167],
|
||||
63: _TokenType_name[167:180],
|
||||
72: _TokenType_name[180:192],
|
||||
73: _TokenType_name[192:202],
|
||||
78: _TokenType_name[202:216],
|
||||
83: _TokenType_name[216:230],
|
||||
91: _TokenType_name[230:241],
|
||||
93: _TokenType_name[241:252],
|
||||
94: _TokenType_name[252:267],
|
||||
96: _TokenType_name[267:280],
|
||||
123: _TokenType_name[280:291],
|
||||
124: _TokenType_name[291:305],
|
||||
125: _TokenType_name[305:316],
|
||||
126: _TokenType_name[316:331],
|
||||
171: _TokenType_name[331:342],
|
||||
187: _TokenType_name[342:353],
|
||||
955: _TokenType_name[353:373],
|
||||
8718: _TokenType_name[373:392],
|
||||
8743: _TokenType_name[392:400],
|
||||
8744: _TokenType_name[400:407],
|
||||
8747: _TokenType_name[407:426],
|
||||
8800: _TokenType_name[426:439],
|
||||
8804: _TokenType_name[439:454],
|
||||
8805: _TokenType_name[454:472],
|
||||
9220: _TokenType_name[472:480],
|
||||
9225: _TokenType_name[480:488],
|
||||
10138: _TokenType_name[488:501],
|
||||
65533: _TokenType_name[501:513],
|
||||
128169: _TokenType_name[513:525],
|
||||
}
|
||||
|
||||
func (i TokenType) String() string {
|
||||
if str, ok := _TokenType_map[i]; ok {
|
||||
return str
|
||||
}
|
||||
return fmt.Sprintf("TokenType(%d)", i)
|
||||
}
|
Loading…
Reference in New Issue
Block a user