|
|
|
|
@ -1,10 +1,10 @@
|
|
|
|
|
============================================
|
|
|
|
|
================================================================================
|
|
|
|
|
Qualified type names
|
|
|
|
|
============================================
|
|
|
|
|
================================================================================
|
|
|
|
|
|
|
|
|
|
type a b.c
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
(source_file
|
|
|
|
|
(type_declaration
|
|
|
|
|
@ -14,13 +14,13 @@ type a b.c
|
|
|
|
|
package: (package_identifier)
|
|
|
|
|
name: (type_identifier)))))
|
|
|
|
|
|
|
|
|
|
============================================
|
|
|
|
|
================================================================================
|
|
|
|
|
Array types
|
|
|
|
|
============================================
|
|
|
|
|
================================================================================
|
|
|
|
|
|
|
|
|
|
type a [2+2]c
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
(source_file
|
|
|
|
|
(type_declaration
|
|
|
|
|
@ -32,31 +32,35 @@ type a [2+2]c
|
|
|
|
|
right: (int_literal))
|
|
|
|
|
element: (type_identifier)))))
|
|
|
|
|
|
|
|
|
|
============================================
|
|
|
|
|
================================================================================
|
|
|
|
|
Slice types
|
|
|
|
|
============================================
|
|
|
|
|
================================================================================
|
|
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
type a []c
|
|
|
|
|
type b [][]d
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
(source_file
|
|
|
|
|
(package_clause (package_identifier))
|
|
|
|
|
(package_clause
|
|
|
|
|
(package_identifier))
|
|
|
|
|
(type_declaration
|
|
|
|
|
(type_spec
|
|
|
|
|
(type_identifier)
|
|
|
|
|
(slice_type (type_identifier))))
|
|
|
|
|
(slice_type
|
|
|
|
|
(type_identifier))))
|
|
|
|
|
(type_declaration
|
|
|
|
|
(type_spec
|
|
|
|
|
(type_identifier)
|
|
|
|
|
(slice_type (slice_type (type_identifier))))))
|
|
|
|
|
(slice_type
|
|
|
|
|
(slice_type
|
|
|
|
|
(type_identifier))))))
|
|
|
|
|
|
|
|
|
|
============================================
|
|
|
|
|
================================================================================
|
|
|
|
|
Struct types
|
|
|
|
|
============================================
|
|
|
|
|
================================================================================
|
|
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
@ -83,38 +87,47 @@ type g1 struct {
|
|
|
|
|
|
|
|
|
|
type g2[T, U any, V interface{}, W Foo[Bar[T]]] struct {}
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
(source_file
|
|
|
|
|
(package_clause (package_identifier))
|
|
|
|
|
(package_clause
|
|
|
|
|
(package_identifier))
|
|
|
|
|
(type_declaration
|
|
|
|
|
(type_spec
|
|
|
|
|
(type_identifier)
|
|
|
|
|
(struct_type (field_declaration_list))))
|
|
|
|
|
(struct_type
|
|
|
|
|
(field_declaration_list))))
|
|
|
|
|
(type_declaration
|
|
|
|
|
(type_spec
|
|
|
|
|
(type_identifier)
|
|
|
|
|
(struct_type (field_declaration_list (field_declaration (type_identifier))))))
|
|
|
|
|
(struct_type
|
|
|
|
|
(field_declaration_list
|
|
|
|
|
(field_declaration
|
|
|
|
|
(type_identifier))))))
|
|
|
|
|
(type_declaration
|
|
|
|
|
(type_spec
|
|
|
|
|
(type_identifier)
|
|
|
|
|
(struct_type (field_declaration_list
|
|
|
|
|
(field_declaration
|
|
|
|
|
(field_identifier)
|
|
|
|
|
(field_identifier)
|
|
|
|
|
(type_identifier))))))
|
|
|
|
|
(struct_type
|
|
|
|
|
(field_declaration_list
|
|
|
|
|
(field_declaration
|
|
|
|
|
(field_identifier)
|
|
|
|
|
(field_identifier)
|
|
|
|
|
(type_identifier))))))
|
|
|
|
|
(type_declaration
|
|
|
|
|
(type_spec
|
|
|
|
|
(type_identifier)
|
|
|
|
|
(struct_type (field_declaration_list
|
|
|
|
|
(comment)
|
|
|
|
|
(field_declaration
|
|
|
|
|
(qualified_type (package_identifier) (type_identifier)))
|
|
|
|
|
(comment)
|
|
|
|
|
(field_declaration
|
|
|
|
|
(field_identifier)
|
|
|
|
|
(type_identifier)
|
|
|
|
|
(raw_string_literal))))))
|
|
|
|
|
(struct_type
|
|
|
|
|
(field_declaration_list
|
|
|
|
|
(comment)
|
|
|
|
|
(field_declaration
|
|
|
|
|
(qualified_type
|
|
|
|
|
(package_identifier)
|
|
|
|
|
(type_identifier)))
|
|
|
|
|
(comment)
|
|
|
|
|
(field_declaration
|
|
|
|
|
(field_identifier)
|
|
|
|
|
(type_identifier)
|
|
|
|
|
(raw_string_literal))))))
|
|
|
|
|
(type_declaration
|
|
|
|
|
(type_spec
|
|
|
|
|
(type_identifier)
|
|
|
|
|
@ -153,12 +166,14 @@ type g2[T, U any, V interface{}, W Foo[Bar[T]]] struct {}
|
|
|
|
|
(type_arguments
|
|
|
|
|
(generic_type
|
|
|
|
|
(type_identifier)
|
|
|
|
|
(type_arguments (type_identifier)))))))
|
|
|
|
|
(struct_type (field_declaration_list)))))
|
|
|
|
|
(type_arguments
|
|
|
|
|
(type_identifier)))))))
|
|
|
|
|
(struct_type
|
|
|
|
|
(field_declaration_list)))))
|
|
|
|
|
|
|
|
|
|
============================================
|
|
|
|
|
================================================================================
|
|
|
|
|
Interface types
|
|
|
|
|
============================================
|
|
|
|
|
================================================================================
|
|
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
@ -177,59 +192,142 @@ type SignedInteger interface {
|
|
|
|
|
int | int8 | ~uint | ~uint8
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
(source_file
|
|
|
|
|
(package_clause (package_identifier))
|
|
|
|
|
(type_declaration (type_spec
|
|
|
|
|
(type_identifier)
|
|
|
|
|
(interface_type)))
|
|
|
|
|
(type_declaration (type_spec
|
|
|
|
|
(type_identifier)
|
|
|
|
|
(interface_type (interface_type_name
|
|
|
|
|
(qualified_type (package_identifier) (type_identifier))))))
|
|
|
|
|
(type_declaration (type_spec
|
|
|
|
|
(type_identifier)
|
|
|
|
|
(interface_type
|
|
|
|
|
(interface_type_name (type_identifier))
|
|
|
|
|
(interface_type_name (qualified_type (package_identifier) (type_identifier)))
|
|
|
|
|
(method_spec
|
|
|
|
|
(field_identifier)
|
|
|
|
|
(parameter_list (parameter_declaration (identifier) (type_identifier)))
|
|
|
|
|
(type_identifier))
|
|
|
|
|
(method_spec
|
|
|
|
|
(field_identifier)
|
|
|
|
|
(package_clause
|
|
|
|
|
(package_identifier))
|
|
|
|
|
(type_declaration
|
|
|
|
|
(type_spec
|
|
|
|
|
(type_identifier)
|
|
|
|
|
(interface_type)))
|
|
|
|
|
(type_declaration
|
|
|
|
|
(type_spec
|
|
|
|
|
(type_identifier)
|
|
|
|
|
(interface_type
|
|
|
|
|
(interface_type_name
|
|
|
|
|
(qualified_type
|
|
|
|
|
(package_identifier)
|
|
|
|
|
(type_identifier))))))
|
|
|
|
|
(type_declaration
|
|
|
|
|
(type_spec
|
|
|
|
|
(type_identifier)
|
|
|
|
|
(interface_type
|
|
|
|
|
(interface_type_name
|
|
|
|
|
(type_identifier))
|
|
|
|
|
(interface_type_name
|
|
|
|
|
(qualified_type
|
|
|
|
|
(package_identifier)
|
|
|
|
|
(type_identifier)))
|
|
|
|
|
(method_spec
|
|
|
|
|
(field_identifier)
|
|
|
|
|
(parameter_list
|
|
|
|
|
(parameter_declaration (type_identifier))
|
|
|
|
|
(variadic_parameter_declaration (type_identifier))) (type_identifier)))))
|
|
|
|
|
(type_declaration (type_spec
|
|
|
|
|
(type_identifier)
|
|
|
|
|
(interface_type (constraint_elem
|
|
|
|
|
(constraint_term (type_identifier))
|
|
|
|
|
(constraint_term (type_identifier))
|
|
|
|
|
(constraint_term (type_identifier))
|
|
|
|
|
(constraint_term (type_identifier)))))))
|
|
|
|
|
|
|
|
|
|
============================================
|
|
|
|
|
(parameter_declaration
|
|
|
|
|
(identifier)
|
|
|
|
|
(type_identifier)))
|
|
|
|
|
(type_identifier))
|
|
|
|
|
(method_spec
|
|
|
|
|
(field_identifier)
|
|
|
|
|
(parameter_list
|
|
|
|
|
(parameter_declaration
|
|
|
|
|
(type_identifier))
|
|
|
|
|
(variadic_parameter_declaration
|
|
|
|
|
(type_identifier)))
|
|
|
|
|
(type_identifier)))))
|
|
|
|
|
(type_declaration
|
|
|
|
|
(type_spec
|
|
|
|
|
(type_identifier)
|
|
|
|
|
(interface_type
|
|
|
|
|
(constraint_elem
|
|
|
|
|
(constraint_term
|
|
|
|
|
(type_identifier))
|
|
|
|
|
(constraint_term
|
|
|
|
|
(type_identifier))
|
|
|
|
|
(constraint_term
|
|
|
|
|
(type_identifier))
|
|
|
|
|
(constraint_term
|
|
|
|
|
(type_identifier)))))))
|
|
|
|
|
|
|
|
|
|
================================================================================
|
|
|
|
|
Interface embedded struct types
|
|
|
|
|
================================================================================
|
|
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
type NewEmbeddings interface {
|
|
|
|
|
struct{ f int }
|
|
|
|
|
~struct{ f int }
|
|
|
|
|
*struct{ f int }
|
|
|
|
|
struct{ f int } | ~struct{ f int }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
(source_file
|
|
|
|
|
(package_clause
|
|
|
|
|
(package_identifier))
|
|
|
|
|
(type_declaration
|
|
|
|
|
(type_spec
|
|
|
|
|
(type_identifier)
|
|
|
|
|
(interface_type
|
|
|
|
|
(struct_elem
|
|
|
|
|
(struct_term
|
|
|
|
|
(struct_type
|
|
|
|
|
(field_declaration_list
|
|
|
|
|
(field_declaration
|
|
|
|
|
(field_identifier)
|
|
|
|
|
(type_identifier))))))
|
|
|
|
|
(struct_elem
|
|
|
|
|
(struct_term
|
|
|
|
|
(struct_type
|
|
|
|
|
(field_declaration_list
|
|
|
|
|
(field_declaration
|
|
|
|
|
(field_identifier)
|
|
|
|
|
(type_identifier))))))
|
|
|
|
|
(struct_elem
|
|
|
|
|
(struct_term
|
|
|
|
|
(struct_type
|
|
|
|
|
(field_declaration_list
|
|
|
|
|
(field_declaration
|
|
|
|
|
(field_identifier)
|
|
|
|
|
(type_identifier))))))
|
|
|
|
|
(struct_elem
|
|
|
|
|
(struct_term
|
|
|
|
|
(struct_type
|
|
|
|
|
(field_declaration_list
|
|
|
|
|
(field_declaration
|
|
|
|
|
(field_identifier)
|
|
|
|
|
(type_identifier)))))
|
|
|
|
|
(struct_term
|
|
|
|
|
(struct_type
|
|
|
|
|
(field_declaration_list
|
|
|
|
|
(field_declaration
|
|
|
|
|
(field_identifier)
|
|
|
|
|
(type_identifier))))))))))
|
|
|
|
|
|
|
|
|
|
================================================================================
|
|
|
|
|
Map types
|
|
|
|
|
============================================
|
|
|
|
|
================================================================================
|
|
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
type m1 map[string]error
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
(source_file
|
|
|
|
|
(package_clause (package_identifier))
|
|
|
|
|
(package_clause
|
|
|
|
|
(package_identifier))
|
|
|
|
|
(type_declaration
|
|
|
|
|
(type_spec
|
|
|
|
|
(type_identifier)
|
|
|
|
|
(map_type (type_identifier) (type_identifier)))))
|
|
|
|
|
(map_type
|
|
|
|
|
(type_identifier)
|
|
|
|
|
(type_identifier)))))
|
|
|
|
|
|
|
|
|
|
============================================
|
|
|
|
|
================================================================================
|
|
|
|
|
Pointer types
|
|
|
|
|
============================================
|
|
|
|
|
================================================================================
|
|
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
@ -238,21 +336,25 @@ type (
|
|
|
|
|
p2 **p1
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
(source_file
|
|
|
|
|
(package_clause (package_identifier))
|
|
|
|
|
(package_clause
|
|
|
|
|
(package_identifier))
|
|
|
|
|
(type_declaration
|
|
|
|
|
(type_spec
|
|
|
|
|
(type_identifier)
|
|
|
|
|
(pointer_type (type_identifier)))
|
|
|
|
|
(pointer_type
|
|
|
|
|
(type_identifier)))
|
|
|
|
|
(type_spec
|
|
|
|
|
(type_identifier)
|
|
|
|
|
(pointer_type (pointer_type (type_identifier))))))
|
|
|
|
|
(pointer_type
|
|
|
|
|
(pointer_type
|
|
|
|
|
(type_identifier))))))
|
|
|
|
|
|
|
|
|
|
============================================
|
|
|
|
|
================================================================================
|
|
|
|
|
Channel types
|
|
|
|
|
============================================
|
|
|
|
|
================================================================================
|
|
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
@ -262,24 +364,32 @@ type (
|
|
|
|
|
c3 chan<- <-chan int
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
(source_file
|
|
|
|
|
(package_clause (package_identifier))
|
|
|
|
|
(package_clause
|
|
|
|
|
(package_identifier))
|
|
|
|
|
(type_declaration
|
|
|
|
|
(type_spec
|
|
|
|
|
(type_identifier)
|
|
|
|
|
(channel_type (channel_type (type_identifier))))
|
|
|
|
|
(channel_type
|
|
|
|
|
(channel_type
|
|
|
|
|
(type_identifier))))
|
|
|
|
|
(type_spec
|
|
|
|
|
(type_identifier)
|
|
|
|
|
(channel_type (channel_type (struct_type (field_declaration_list)))))
|
|
|
|
|
(channel_type
|
|
|
|
|
(channel_type
|
|
|
|
|
(struct_type
|
|
|
|
|
(field_declaration_list)))))
|
|
|
|
|
(type_spec
|
|
|
|
|
(type_identifier)
|
|
|
|
|
(channel_type (channel_type (type_identifier))))))
|
|
|
|
|
(channel_type
|
|
|
|
|
(channel_type
|
|
|
|
|
(type_identifier))))))
|
|
|
|
|
|
|
|
|
|
============================================
|
|
|
|
|
================================================================================
|
|
|
|
|
Function types
|
|
|
|
|
============================================
|
|
|
|
|
================================================================================
|
|
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
@ -289,38 +399,47 @@ type (
|
|
|
|
|
c func(int, ...*string) bool
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
(source_file
|
|
|
|
|
(package_clause (package_identifier))
|
|
|
|
|
(package_clause
|
|
|
|
|
(package_identifier))
|
|
|
|
|
(type_declaration
|
|
|
|
|
(type_spec
|
|
|
|
|
(type_identifier)
|
|
|
|
|
(function_type
|
|
|
|
|
(parameter_list
|
|
|
|
|
(parameter_declaration (type_identifier)))
|
|
|
|
|
(parameter_declaration
|
|
|
|
|
(type_identifier)))
|
|
|
|
|
(type_identifier)))
|
|
|
|
|
(type_spec
|
|
|
|
|
(type_identifier)
|
|
|
|
|
(function_type
|
|
|
|
|
(parameter_list
|
|
|
|
|
(parameter_declaration (type_identifier))
|
|
|
|
|
(parameter_declaration (pointer_type (type_identifier))))
|
|
|
|
|
(parameter_declaration
|
|
|
|
|
(type_identifier))
|
|
|
|
|
(parameter_declaration
|
|
|
|
|
(pointer_type
|
|
|
|
|
(type_identifier))))
|
|
|
|
|
(parameter_list
|
|
|
|
|
(parameter_declaration (type_identifier))
|
|
|
|
|
(parameter_declaration (type_identifier)))))
|
|
|
|
|
(parameter_declaration
|
|
|
|
|
(type_identifier))
|
|
|
|
|
(parameter_declaration
|
|
|
|
|
(type_identifier)))))
|
|
|
|
|
(type_spec
|
|
|
|
|
(type_identifier)
|
|
|
|
|
(function_type
|
|
|
|
|
(parameter_list
|
|
|
|
|
(parameter_declaration (type_identifier))
|
|
|
|
|
(parameter_declaration
|
|
|
|
|
(type_identifier))
|
|
|
|
|
(variadic_parameter_declaration
|
|
|
|
|
(pointer_type (type_identifier))))
|
|
|
|
|
(pointer_type
|
|
|
|
|
(type_identifier))))
|
|
|
|
|
(type_identifier)))))
|
|
|
|
|
|
|
|
|
|
============================================
|
|
|
|
|
================================================================================
|
|
|
|
|
Type Aliases
|
|
|
|
|
============================================
|
|
|
|
|
================================================================================
|
|
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
@ -336,20 +455,43 @@ type (
|
|
|
|
|
A5 = Value
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
(source_file
|
|
|
|
|
(package_clause (package_identifier))
|
|
|
|
|
(package_clause
|
|
|
|
|
(package_identifier))
|
|
|
|
|
(type_declaration
|
|
|
|
|
(type_alias
|
|
|
|
|
(type_identifier)
|
|
|
|
|
(type_identifier)))
|
|
|
|
|
(type_declaration
|
|
|
|
|
(type_alias (type_identifier) (type_identifier)))
|
|
|
|
|
(type_alias
|
|
|
|
|
(type_identifier)
|
|
|
|
|
(type_identifier)))
|
|
|
|
|
(type_declaration
|
|
|
|
|
(type_alias (type_identifier) (type_identifier)))
|
|
|
|
|
(type_alias
|
|
|
|
|
(type_identifier)
|
|
|
|
|
(struct_type
|
|
|
|
|
(field_declaration_list))))
|
|
|
|
|
(type_declaration
|
|
|
|
|
(type_alias (type_identifier) (struct_type (field_declaration_list))))
|
|
|
|
|
(type_declaration
|
|
|
|
|
(type_alias (type_identifier) (type_identifier))
|
|
|
|
|
(type_alias (type_identifier) (type_identifier))
|
|
|
|
|
(type_alias (type_identifier) (struct_type (field_declaration_list)))
|
|
|
|
|
(type_alias (type_identifier) (qualified_type (package_identifier) (type_identifier)))
|
|
|
|
|
(type_alias (type_identifier) (type_identifier))
|
|
|
|
|
(type_alias (type_identifier) (type_identifier))))
|
|
|
|
|
(type_alias
|
|
|
|
|
(type_identifier)
|
|
|
|
|
(type_identifier))
|
|
|
|
|
(type_alias
|
|
|
|
|
(type_identifier)
|
|
|
|
|
(type_identifier))
|
|
|
|
|
(type_alias
|
|
|
|
|
(type_identifier)
|
|
|
|
|
(struct_type
|
|
|
|
|
(field_declaration_list)))
|
|
|
|
|
(type_alias
|
|
|
|
|
(type_identifier)
|
|
|
|
|
(qualified_type
|
|
|
|
|
(package_identifier)
|
|
|
|
|
(type_identifier)))
|
|
|
|
|
(type_alias
|
|
|
|
|
(type_identifier)
|
|
|
|
|
(type_identifier))
|
|
|
|
|
(type_alias
|
|
|
|
|
(type_identifier)
|
|
|
|
|
(type_identifier))))
|
|
|
|
|
|