init
This commit is contained in:
commit
8f4f858d86
30 changed files with 9765 additions and 0 deletions
86
internal/lang/token.go
Normal file
86
internal/lang/token.go
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
package lang
|
||||
|
||||
type tokenKind string
|
||||
|
||||
const (
|
||||
tokenEOF tokenKind = "EOF"
|
||||
tokenIdent tokenKind = "IDENT"
|
||||
tokenInt tokenKind = "INT"
|
||||
tokenString tokenKind = "STRING"
|
||||
tokenTrue tokenKind = "TRUE"
|
||||
tokenFalse tokenKind = "FALSE"
|
||||
tokenNull tokenKind = "NULL"
|
||||
tokenImport tokenKind = "IMPORT"
|
||||
tokenPackage tokenKind = "PACKAGE"
|
||||
tokenClass tokenKind = "CLASS"
|
||||
tokenWorker tokenKind = "WORKER"
|
||||
tokenInterface tokenKind = "INTERFACE"
|
||||
tokenFun tokenKind = "FUN"
|
||||
tokenOverride tokenKind = "OVERRIDE"
|
||||
tokenVal tokenKind = "VAL"
|
||||
tokenVar tokenKind = "VAR"
|
||||
tokenIf tokenKind = "IF"
|
||||
tokenElse tokenKind = "ELSE"
|
||||
tokenWhile tokenKind = "WHILE"
|
||||
tokenSelect tokenKind = "SELECT"
|
||||
tokenReturn tokenKind = "RETURN"
|
||||
tokenGo tokenKind = "GO"
|
||||
tokenTry tokenKind = "TRY"
|
||||
tokenCatch tokenKind = "CATCH"
|
||||
tokenThrow tokenKind = "THROW"
|
||||
tokenLParen tokenKind = "("
|
||||
tokenRParen tokenKind = ")"
|
||||
tokenLBrace tokenKind = "{"
|
||||
tokenRBrace tokenKind = "}"
|
||||
tokenComma tokenKind = ","
|
||||
tokenDot tokenKind = "."
|
||||
tokenColon tokenKind = ":"
|
||||
tokenSemicolon tokenKind = ";"
|
||||
tokenPlus tokenKind = "+"
|
||||
tokenMinus tokenKind = "-"
|
||||
tokenStar tokenKind = "*"
|
||||
tokenSlash tokenKind = "/"
|
||||
tokenPercent tokenKind = "%"
|
||||
tokenBang tokenKind = "!"
|
||||
tokenAssign tokenKind = "="
|
||||
tokenPlusAssign tokenKind = "+="
|
||||
tokenEq tokenKind = "=="
|
||||
tokenNeq tokenKind = "!="
|
||||
tokenLt tokenKind = "<"
|
||||
tokenLte tokenKind = "<="
|
||||
tokenGt tokenKind = ">"
|
||||
tokenGte tokenKind = ">="
|
||||
tokenAnd tokenKind = "&&"
|
||||
tokenOr tokenKind = "||"
|
||||
tokenArrow tokenKind = "->"
|
||||
)
|
||||
|
||||
var keywords = map[string]tokenKind{
|
||||
"fun": tokenFun,
|
||||
"import": tokenImport,
|
||||
"package": tokenPackage,
|
||||
"class": tokenClass,
|
||||
"worker": tokenWorker,
|
||||
"interface": tokenInterface,
|
||||
"val": tokenVal,
|
||||
"var": tokenVar,
|
||||
"override": tokenOverride,
|
||||
"if": tokenIf,
|
||||
"else": tokenElse,
|
||||
"while": tokenWhile,
|
||||
"select": tokenSelect,
|
||||
"return": tokenReturn,
|
||||
"go": tokenGo,
|
||||
"try": tokenTry,
|
||||
"catch": tokenCatch,
|
||||
"throw": tokenThrow,
|
||||
"true": tokenTrue,
|
||||
"false": tokenFalse,
|
||||
"null": tokenNull,
|
||||
}
|
||||
|
||||
type token struct {
|
||||
kind tokenKind
|
||||
lexeme string
|
||||
pos int
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue