Token kind values can now be described
This commit is contained in:
parent
f23c3a234a
commit
b3071d4ac9
152
lexer/token.go
152
lexer/token.go
@ -94,78 +94,7 @@ func (token Token) NewError (message string, kind file.ErrorKind) (err file.Erro
|
||||
// Describe generates a textual description of the token to be used in debug
|
||||
// logs.
|
||||
func (token Token) Describe () (description string) {
|
||||
switch token.kind {
|
||||
case TokenKindNewline:
|
||||
description += "Newline"
|
||||
case TokenKindIndent:
|
||||
description += "Indent"
|
||||
case TokenKindSeparator:
|
||||
description += "Separator"
|
||||
case TokenKindPermission:
|
||||
description += "Permission"
|
||||
case TokenKindReturnDirection:
|
||||
description += "ReturnDirection"
|
||||
case TokenKindInt:
|
||||
description += "Int"
|
||||
case TokenKindUInt:
|
||||
description += "UInt"
|
||||
case TokenKindFloat:
|
||||
description += "Float"
|
||||
case TokenKindString:
|
||||
description += "String"
|
||||
case TokenKindRune:
|
||||
description += "Rune"
|
||||
case TokenKindName:
|
||||
description += "Name"
|
||||
case TokenKindColon:
|
||||
description += "Colon"
|
||||
case TokenKindDot:
|
||||
description += "Dot"
|
||||
case TokenKindLBracket:
|
||||
description += "LBracket"
|
||||
case TokenKindRBracket:
|
||||
description += "RBracket"
|
||||
case TokenKindLBrace:
|
||||
description += "LBrace"
|
||||
case TokenKindRBrace:
|
||||
description += "RBrace"
|
||||
case TokenKindPlus:
|
||||
description += "Plus"
|
||||
case TokenKindMinus:
|
||||
description += "Minus"
|
||||
case TokenKindIncrement:
|
||||
description += "Increment"
|
||||
case TokenKindDecrement:
|
||||
description += "Decrement"
|
||||
case TokenKindAsterisk:
|
||||
description += "Asterisk"
|
||||
case TokenKindSlash:
|
||||
description += "Slash"
|
||||
case TokenKindAt:
|
||||
description += "At"
|
||||
case TokenKindExclamation:
|
||||
description += "Exclamation"
|
||||
case TokenKindPercent:
|
||||
description += "Percent"
|
||||
case TokenKindTilde:
|
||||
description += "Tilde"
|
||||
case TokenKindLessThan:
|
||||
description += "LessThan"
|
||||
case TokenKindLShift:
|
||||
description += "LShift"
|
||||
case TokenKindGreaterThan:
|
||||
description += "GreaterThan"
|
||||
case TokenKindRShift:
|
||||
description += "RShift"
|
||||
case TokenKindBinaryOr:
|
||||
description += "BinaryOr"
|
||||
case TokenKindLogicalOr:
|
||||
description += "LogicalOr"
|
||||
case TokenKindBinaryAnd:
|
||||
description += "BinaryAnd"
|
||||
case TokenKindLogicalAnd:
|
||||
description += "LogicalAnd"
|
||||
}
|
||||
description = token.kind.Describe()
|
||||
|
||||
if token.value != nil {
|
||||
description += fmt.Sprint(": ", token.value)
|
||||
@ -173,3 +102,82 @@ func (token Token) Describe () (description string) {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Describe generates a textual description of the token kind to be used in
|
||||
// debug logs.
|
||||
func (tokenKind TokenKind) Describe () (description string) {
|
||||
switch tokenKind {
|
||||
case TokenKindNewline:
|
||||
description = "Newline"
|
||||
case TokenKindIndent:
|
||||
description = "Indent"
|
||||
case TokenKindSeparator:
|
||||
description = "Separator"
|
||||
case TokenKindPermission:
|
||||
description = "Permission"
|
||||
case TokenKindReturnDirection:
|
||||
description = "ReturnDirection"
|
||||
case TokenKindInt:
|
||||
description = "Int"
|
||||
case TokenKindUInt:
|
||||
description = "UInt"
|
||||
case TokenKindFloat:
|
||||
description = "Float"
|
||||
case TokenKindString:
|
||||
description = "String"
|
||||
case TokenKindRune:
|
||||
description = "Rune"
|
||||
case TokenKindName:
|
||||
description = "Name"
|
||||
case TokenKindColon:
|
||||
description = "Colon"
|
||||
case TokenKindDot:
|
||||
description = "Dot"
|
||||
case TokenKindLBracket:
|
||||
description = "LBracket"
|
||||
case TokenKindRBracket:
|
||||
description = "RBracket"
|
||||
case TokenKindLBrace:
|
||||
description = "LBrace"
|
||||
case TokenKindRBrace:
|
||||
description = "RBrace"
|
||||
case TokenKindPlus:
|
||||
description = "Plus"
|
||||
case TokenKindMinus:
|
||||
description = "Minus"
|
||||
case TokenKindIncrement:
|
||||
description = "Increment"
|
||||
case TokenKindDecrement:
|
||||
description = "Decrement"
|
||||
case TokenKindAsterisk:
|
||||
description = "Asterisk"
|
||||
case TokenKindSlash:
|
||||
description = "Slash"
|
||||
case TokenKindAt:
|
||||
description = "At"
|
||||
case TokenKindExclamation:
|
||||
description = "Exclamation"
|
||||
case TokenKindPercent:
|
||||
description = "Percent"
|
||||
case TokenKindTilde:
|
||||
description = "Tilde"
|
||||
case TokenKindLessThan:
|
||||
description = "LessThan"
|
||||
case TokenKindLShift:
|
||||
description = "LShift"
|
||||
case TokenKindGreaterThan:
|
||||
description = "GreaterThan"
|
||||
case TokenKindRShift:
|
||||
description = "RShift"
|
||||
case TokenKindBinaryOr:
|
||||
description = "BinaryOr"
|
||||
case TokenKindLogicalOr:
|
||||
description = "LogicalOr"
|
||||
case TokenKindBinaryAnd:
|
||||
description = "BinaryAnd"
|
||||
case TokenKindLogicalAnd:
|
||||
description = "LogicalAnd"
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user