feat: generate ast.Type "enum"
This commit is contained in:
parent
b2e5aefaa7
commit
92d341cbb5
@ -21,6 +21,10 @@ func (n *ParserBrackets) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *ParserBrackets) GetType() ast.Type {
|
||||
return ast.TypeNone
|
||||
}
|
||||
|
||||
type ParserSeparatedList struct {
|
||||
Position *position.Position
|
||||
Items []ast.Vertex
|
||||
@ -35,6 +39,10 @@ func (n *ParserSeparatedList) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *ParserSeparatedList) GetType() ast.Type {
|
||||
return ast.TypeNone
|
||||
}
|
||||
|
||||
// TraitAdaptationList node
|
||||
type TraitAdaptationList struct {
|
||||
Position *position.Position
|
||||
@ -51,6 +59,10 @@ func (n *TraitAdaptationList) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *TraitAdaptationList) GetType() ast.Type {
|
||||
return ast.TypeNone
|
||||
}
|
||||
|
||||
// ArgumentList node
|
||||
type ArgumentList struct {
|
||||
Position *position.Position
|
||||
@ -68,6 +80,10 @@ func (n *ArgumentList) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *ArgumentList) GetType() ast.Type {
|
||||
return ast.TypeNone
|
||||
}
|
||||
|
||||
type ReturnType struct {
|
||||
Position *position.Position
|
||||
ColonTkn *token.Token
|
||||
@ -82,6 +98,10 @@ func (n *ReturnType) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *ReturnType) GetType() ast.Type {
|
||||
return ast.TypeNone
|
||||
}
|
||||
|
||||
// TraitMethodRef node
|
||||
type TraitMethodRef struct {
|
||||
Position *position.Position
|
||||
@ -97,3 +117,7 @@ func (n *TraitMethodRef) Accept(v ast.Visitor) {
|
||||
func (n *TraitMethodRef) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *TraitMethodRef) GetType() ast.Type {
|
||||
return ast.TypeNone
|
||||
}
|
||||
|
@ -21,6 +21,10 @@ func (n *ParserBrackets) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *ParserBrackets) GetType() ast.Type {
|
||||
return ast.TypeNone
|
||||
}
|
||||
|
||||
type ParserSeparatedList struct {
|
||||
Position *position.Position
|
||||
Items []ast.Vertex
|
||||
@ -35,6 +39,10 @@ func (n *ParserSeparatedList) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *ParserSeparatedList) GetType() ast.Type {
|
||||
return ast.TypeNone
|
||||
}
|
||||
|
||||
// TraitAdaptationList node
|
||||
type TraitAdaptationList struct {
|
||||
Position *position.Position
|
||||
@ -51,6 +59,10 @@ func (n *TraitAdaptationList) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *TraitAdaptationList) GetType() ast.Type {
|
||||
return ast.TypeNone
|
||||
}
|
||||
|
||||
// ArgumentList node
|
||||
type ArgumentList struct {
|
||||
Position *position.Position
|
||||
@ -69,6 +81,10 @@ func (n *ArgumentList) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *ArgumentList) GetType() ast.Type {
|
||||
return ast.TypeNone
|
||||
}
|
||||
|
||||
type EnumCaseExpr struct {
|
||||
Position *position.Position
|
||||
AssignTkn *token.Token
|
||||
@ -83,6 +99,10 @@ func (n *EnumCaseExpr) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *EnumCaseExpr) GetType() ast.Type {
|
||||
return ast.TypeNone
|
||||
}
|
||||
|
||||
type ReturnType struct {
|
||||
Position *position.Position
|
||||
ColonTkn *token.Token
|
||||
@ -97,6 +117,10 @@ func (n *ReturnType) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *ReturnType) GetType() ast.Type {
|
||||
return ast.TypeNone
|
||||
}
|
||||
|
||||
// TraitMethodRef node
|
||||
type TraitMethodRef struct {
|
||||
Position *position.Position
|
||||
@ -112,3 +136,7 @@ func (n *TraitMethodRef) Accept(v ast.Visitor) {
|
||||
func (n *TraitMethodRef) GetPosition() *position.Position {
|
||||
return n.Position
|
||||
}
|
||||
|
||||
func (n *TraitMethodRef) GetType() ast.Type {
|
||||
return ast.TypeNone
|
||||
}
|
||||
|
@ -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
@ -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}}`),
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user