All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.textmapper.tool.templates.go_token.ltp Maven / Gradle / Ivy

The newest version!
${template main-}
${file 'token.go'-}
${call token-}
${end-}
${end}

${template token-}
package ${opts.lang}

import (
	"fmt"
)

type Token int

const (
	UNAVAILABLE Token = iota - 1

	// An end-of-input marker token.
	EOI

${for i in [1, syntax.terminals - 1]-}
	${syntax.symbols[i].id->java.escapeJavaReserved()}${if syntax.symbols[i].isConstant()} // ${util.escape(syntax.symbols[i].getConstantValue())}${end}
${end-}

	terminalEnd
)

var tokenStr = [...]string{
	"EOF",

${for i in [1, syntax.terminals - 1]-}
	"${util.escape(syntax.symbols[i].isConstant() ? util.escape(syntax.symbols[i].getConstantValue()) : syntax.symbols[i].id)}",
${end-}
}

func (tok Token) String() string {
	if tok >= 0 && int(tok) < len(tokenStr) {
		return tokenStr[tok]
	}
	return fmt.Sprintf("token(%d)", tok)
}
${end}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy