Serialize and deserialize Tokens as strings

This commit is contained in:
Tobie Morgan Hitchcock 2016-11-04 11:16:41 +00:00
parent b0ab86c4ef
commit 57f49576db

View file

@ -414,6 +414,13 @@ func (tok Token) String() string {
return "" 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 } func (tok Token) isLiteral() bool { return tok > literalsBeg && tok < literalsEnd }