1
0
mirror of https://github.com/robertkrimen/otto synced 2025-10-19 19:55:30 +08:00
otto/tools/gen-tokens/templates/root.tmpl
Steven Hartland b882379002
chore: add generated headers (#486)
Add headers to generated files so that editors will notify users that
these files shouldn't be edited manually.
2023-01-13 19:47:05 +00:00

55 lines
1.4 KiB
Cheetah

// Code generated by tools/gen-tokens. DO NOT EDIT.
package token
const (
_ Token = iota
{{range .Tokens}}
{{- if not .Future}}
{{- if .Group}}
// {{.Group}}.
{{- else}}
{{.Name}} {{- if .Symbol}}// {{.Symbol}}{{end}}
{{- end}}
{{- end}}
{{- end}}
)
var token2string = [...]string{
{{- $lc := false -}}
{{- range .Tokens -}}
{{if or .Future .Group | not -}}
{{- if eq .Name "_" -}}
{{$lc = true}}
{{- else}}
{{- $symbol := or .Symbol .Name}}
{{.Name}}: "{{if $lc}}{{toLower $symbol}}{{else}}{{$symbol}}{{end}}",
{{- end}}
{{- end -}}
{{- end}}
}
var keywordTable = map[string]keyword{
{{- $keyword := false -}}
{{range .Tokens}}
{{- /* First keyword follows _ */ -}}
{{- if eq .Name "_"}}{{$keyword = true}}{{continue}}{{end}}
{{- if $keyword}}
{{- if or .Symbol .Group | not}}
"{{toLower .Name}}": {
{{- if .Future}}
token: KEYWORD,
futureKeyword: true,
{{- else}}
token: {{.Name}},
{{- end}}
{{- if .Strict}}
strict: true,
{{- end}}
},
{{- end -}}
{{end -}}
{{- end}}
}