Serialize and deserialize Tokens as strings
This commit is contained in:
parent
b0ab86c4ef
commit
57f49576db
1 changed files with 7 additions and 0 deletions
|
@ -414,6 +414,13 @@ func (tok Token) String() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func newToken(str string) Token {
|
||||
for k, v := range tokens {
|
||||
if v == str {
|
||||
return Token(k)
|
||||
}
|
||||
}
|
||||
return ILLEGAL
|
||||
}
|
||||
|
||||
func (tok Token) isLiteral() bool { return tok > literalsBeg && tok < literalsEnd }
|
||||
|
|
Loading…
Reference in a new issue