filhodanuvem / gitql

💊 A git query language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Refactor: Make a literal/constant tokens map

filhodanuvem opened this issue · comments

In the lexical package we do

func allocMapTokenNames() {
	if len(tokenNameMap) == 0 {
		tokenNameMap = map[uint8]string{
			T_SELECT:           "T_SELECT",
			T_DISTINCT:         "T_DISTINCT",
			// ... other tokens 
			T_USE:              "T_USE",
		}
	}
}

but this could be avoided with a literal/constant map, we don't need an allocMapTokenNames function. That's a C way of coding that I introduced in the beginning of the project :)

https://github.com/filhodanuvem/gitql/blob/main/lexical/tokens.go

I'd be happy to refactor this.