feat: generate ast.Type "enum"

This commit is contained in:
Laytan Laats
2023-03-26 21:31:37 +02:00
parent b2e5aefaa7
commit 92d341cbb5
5 changed files with 904 additions and 0 deletions

View File

@@ -14,6 +14,7 @@ var TypeToVisitorNameMap = map[string]string{
type Vertex interface {
Accept(v Visitor)
GetPosition() *position.Position
GetType() Type
}
type Visitor interface {

File diff suppressed because it is too large Load Diff

View File

@@ -28,6 +28,16 @@ var fileTempl = template.Must(
package ast
import "github.com/VKCOM/php-parser/pkg/position"
type Type int
const (
TypeNone Type = iota
{{- range $i, $typ := .Types }}
Type{{ $typ.Name }}
{{- end }}
TypeCount
)
{{range $typ := .Types}}
var _ Vertex = &{{$typ.Name}}{}
@@ -38,6 +48,10 @@ func (n *{{$typ.Name}}) Accept(v Visitor) {
func (n *{{$typ.Name}}) GetPosition() *position.Position {
return n.Position
}
func (n *{{$typ.Name}}) GetType() Type {
return Type{{$typ.Name}}
}
{{end}}`),
)