diff --git a/go.mod b/go.mod index c26d67a3..fda09188 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( github.com/iris-contrib/schema v0.0.6 github.com/json-iterator/go v1.1.12 github.com/kataras/blocks v0.0.8 - github.com/kataras/golog v0.1.15 + github.com/kataras/golog v0.1.12 github.com/kataras/jwt v0.1.17 github.com/kataras/neffos v0.0.24 github.com/kataras/pio v0.0.13 diff --git a/go.sum b/go.sum index 366920e9..6627c8eb 100644 --- a/go.sum +++ b/go.sum @@ -95,8 +95,8 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/kataras/blocks v0.0.8 h1:MrpVhoFTCR2v1iOOfGng5VJSILKeZZI+7NGfxEh3SUM= github.com/kataras/blocks v0.0.8/go.mod h1:9Jm5zx6BB+06NwA+OhTbHW1xkMOYxahnqTN5DveZ2Yg= -github.com/kataras/golog v0.1.15 h1:gDNOENbbn+6me98UW1f9Cs5MRUlAkabnNvmgLFM58Xw= -github.com/kataras/golog v0.1.15/go.mod h1:Ozu1TDa+OKC7fFe7OG64In71yLxjda+6kPl+Rg3v1hA= +github.com/kataras/golog v0.1.12 h1:Bu7I/G4ilJlbfzjmU39O9N+2uO1pBcMK045fzZ4ytNg= +github.com/kataras/golog v0.1.12/go.mod h1:wrGSbOiBqbQSQznleVNX4epWM8rl9SJ/rmEacl0yqy4= github.com/kataras/jwt v0.1.17 h1:dYjemzcdYqA4ylwq9/56MslCr/pNOyVUZ2bl3hYNHgc= github.com/kataras/jwt v0.1.17/go.mod h1:HUnU5HDBCDanVF8zrPVSE2VK8HicospKefZDD4DzOKU= github.com/kataras/neffos v0.0.24 h1:S3lHqJopCfXN285VdlbGeOj+Id83u4xdQKToa+w1vW0= diff --git a/macro/interpreter/token/token.go b/macro/interpreter/token/token.go index 115953b5..e40169c6 100644 --- a/macro/interpreter/token/token.go +++ b/macro/interpreter/token/token.go @@ -1,8 +1,20 @@ package token +import "strconv" + // Type is a specific type of int which describes the symbols. type Type int +// String returns the name of the token type, e.g. "LBRACE" for the '{' symbol. +// It returns the numeric value of an unknown type as it is. +func (t Type) String() string { + if name, ok := typeNames[t]; ok { + return name + } + + return strconv.Itoa(int(t)) +} + // Token describes the letter(s) or symbol, is a result of the lexer. type Token struct { Type Type @@ -37,6 +49,20 @@ const ( INT // 42 ) +var typeNames = map[Type]string{ + EOF: "EOF", + ILLEGAL: "ILLEGAL", + LBRACE: "LBRACE", + RBRACE: "RBRACE", + COLON: "COLON", + LPAREN: "LPAREN", + RPAREN: "RPAREN", + COMMA: "COMMA", + IDENT: "IDENT", + ELSE: "ELSE", + INT: "INT", +} + var keywords = map[string]Type{ "else": ELSE, }