mirror of
https://github.com/robertkrimen/otto
synced 2025-10-26 20:28:49 +08:00
Remove the dependencies on perl and make. inline.pl is replaced by tools/gen-jscore and token/tokenfmt is replaced by tools/gen-tokens which are both golang text/template utilities. gen-jscore uses property ordering that matches chromes output ordering adding missing properties to the Error types. Local generated documentation have been removed as https://pkg.go.dev/ is more feature rich. The use of make has been removed as the functionality is now replicated by standard golang tools go test ./... and go generate ./... as well as integrated into github actions.
53 lines
1.4 KiB
Cheetah
53 lines
1.4 KiB
Cheetah
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}}
|
|
}
|