代码拉取完成,页面将自动刷新
package main
const (
// Single-character tokens.
LEFT_PAREN uint8 = iota
RIGHT_PAREN
LEFT_BRACE
RIGHT_BRACE
COMMA
DOT
MINUS
PLUS
SEMICOLON
SLASH
STAR
// One or two character tokens.
BANG
BANG_EQUAL
EQUAL
EQUAL_EQUAL
GREATER
GREATER_EQUAL
LESS
LESS_EQUAL
// Literals.
IDENTIFIER
STRING
NUMBER
// Keywords.
AND
ELSE
FALSE
FUN
FOR
IF
NIL
OR
PRINT
RETURN
TRUE
VAR
WHILE
// End of file.
EOF
)
type Token struct {
tokenType uint8
lexeme string
literal interface{}
line int
}
func _Token(tokenType uint8, lexeme string, literal interface{}, line int) Token {
return Token{tokenType: tokenType, lexeme: lexeme, literal: literal, line: line}
}
func findType(text string) uint8 {
switch text {
case "and":
return AND
case "else":
return ELSE
case "false":
return FALSE
case "for":
return FOR
case "fun":
return FUN
case "if":
return IF
case "nil":
return NIL
case "or":
return OR
case "print":
return PRINT
case "return":
return RETURN
case "true":
return TRUE
case "var":
return VAR
case "while":
return WHILE
default:
return IDENTIFIER
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。