Debian Codegraph @

tools/gen-tokens/templates/root.tmpl

raw
1 // Code generated by tools/gen-tokens. DO NOT EDIT.
2
3 package token
4
5 const (
6 _ Token = iota
7 {{range .Tokens}}
8 {{- if not .Future}}
9 {{- if .Group}}
10 // {{.Group}}.
11 {{- else}}
12 {{.Name}} {{- if .Symbol}}// {{.Symbol}}{{end}}
13 {{- end}}
14 {{- end}}
15 {{- end}}
16 )
17
18
19 var token2string = [...]string{
20 {{- $lc := false -}}
21 {{- range .Tokens -}}
22 {{if or .Future .Group | not -}}
23 {{- if eq .Name "_" -}}
24 {{$lc = true}}
25 {{- else}}
26 {{- $symbol := or .Symbol .Name}}
27 {{.Name}}: "{{if $lc}}{{toLower $symbol}}{{else}}{{$symbol}}{{end}}",
28 {{- end}}
29 {{- end -}}
30 {{- end}}
31 }
32
33 var keywordTable = map[string]keyword{
34 {{- $keyword := false -}}
35 {{range .Tokens}}
36 {{- /* First keyword follows _ */ -}}
37 {{- if eq .Name "_"}}{{$keyword = true}}{{continue}}{{end}}
38 {{- if $keyword}}
39 {{- if or .Symbol .Group | not}}
40 "{{toLower .Name}}": {
41 {{- if .Future}}
42 token: KEYWORD,
43 futureKeyword: true,
44 {{- else}}
45 token: {{.Name}},
46 {{- end}}
47 {{- if .Strict}}
48 strict: true,
49 {{- end}}
50 },
51 {{- end -}}
52 {{end -}}
53 {{- end}}
54 }