package saccharine import ( "fmt" "git.maximhutz.com/max/lambda/pkg/token" ) // A TokenType is an identifier for any token in the Saccharine language. type TokenType int // All official tokens of the Saccharine language. const ( // TokenOpenParen denotes the '(' token. TokenOpenParen TokenType = iota // TokenCloseParen denotes the ')' token. TokenCloseParen // TokenOpenBrace denotes the '{' token. TokenOpenBrace // TokenCloseBrace denotes the '}' token. TokenCloseBrace // TokenHardBreak denotes the ';' token. TokenHardBreak // TokenAssign denotes the ':=' token. TokenAssign // TokenAtom denotes an alpha-numeric variable. TokenAtom // TokenSlash denotes the '\\' token. TokenSlash // TokenDot denotes the '.' token. TokenDot // TokenSoftBreak denotes a new-line. TokenSoftBreak ) // Name returns the type of the TokenType, as a string. func (t TokenType) Name() string { switch t { case TokenOpenParen: return "(" case TokenCloseParen: return ")" case TokenOpenBrace: return "{" case TokenCloseBrace: return "}" case TokenHardBreak: return ";" case TokenAssign: return ":=" case TokenAtom: return "ATOM" case TokenSlash: return "\\" case TokenDot: return "." case TokenSoftBreak: return "\\n" default: panic(fmt.Errorf("unknown token type %v", t)) } } // Token is the concrete token type for the Saccharine language. type Token = token.Token[TokenType]