Names are now composed from a nameable struct
This commit is contained in:
		
							parent
							
								
									729ae78eae
								
							
						
					
					
						commit
						8e74216430
					
				| @ -41,12 +41,16 @@ func (parser *ParsingOperation) parseArgument () (argument Argument, err error) | |||||||
| 					infoerr.ErrorKindError) | 					infoerr.ErrorKindError) | ||||||
| 				return | 				return | ||||||
| 			} | 			} | ||||||
| 
 | 			 | ||||||
| 			argument.kind  = ArgumentKindDeclaration | 			declaration := Declaration { | ||||||
| 			argument.value = Declaration { |  | ||||||
| 				name: identifier.trail[0], |  | ||||||
| 				what: what, | 				what: what, | ||||||
| 			} | 			} | ||||||
|  | 			declaration.setName(identifier.trail[0]) | ||||||
|  | 			declaration.setLocation(argument.Location()) | ||||||
|  | 
 | ||||||
|  | 			argument.kind  = ArgumentKindDeclaration | ||||||
|  | 			argument.value = declaration | ||||||
|  | 			 | ||||||
| 		} else { | 		} else { | ||||||
| 			argument.kind  = ArgumentKindIdentifier | 			argument.kind  = ArgumentKindIdentifier | ||||||
| 			argument.value = identifier | 			argument.value = identifier | ||||||
|  | |||||||
| @ -9,13 +9,13 @@ type locatable struct { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // Location returns the location of the node. | // Location returns the location of the node. | ||||||
| func (trait locatable) Location (location file.Location) { | func (trait locatable) Location () (location file.Location) { | ||||||
| 	location = trait.location | 	location = trait.location | ||||||
| 	return | 	return | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // setLocation sets the location of the node. | // setLocation sets the location of the node. | ||||||
| func (trait locatable) setLocation (location file.Location) { | func (trait* locatable) setLocation (location file.Location) { | ||||||
| 	trait.location = location | 	trait.location = location | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -28,3 +28,18 @@ func (trait locatable) NewError ( | |||||||
| ) { | ) { | ||||||
| 	return infoerr.NewError(trait.location, message, kind) | 	return infoerr.NewError(trait.location, message, kind) | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | // nameable allows a tree node to have a name. | ||||||
|  | type nameable struct { | ||||||
|  | 	name string | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // Name returns the name of the node. | ||||||
|  | func (trait nameable) Name () (name string) { | ||||||
|  | 	name = trait.name | ||||||
|  | 	return | ||||||
|  | } | ||||||
|  | // setName sets the name of the node. | ||||||
|  | func (trait *nameable) setName (name string) { | ||||||
|  | 	trait.name = name | ||||||
|  | } | ||||||
|  | |||||||
| @ -61,7 +61,7 @@ type Type struct { | |||||||
| // Declaration represents a variable declaration. | // Declaration represents a variable declaration. | ||||||
| type Declaration struct { | type Declaration struct { | ||||||
| 	locatable | 	locatable | ||||||
| 	name string | 	nameable | ||||||
| 	what Type | 	what Type | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -149,7 +149,7 @@ type Argument struct { | |||||||
| // DataSection represents a global variable. | // DataSection represents a global variable. | ||||||
| type DataSection struct { | type DataSection struct { | ||||||
| 	locatable | 	locatable | ||||||
| 	name string | 	nameable | ||||||
| 	 | 	 | ||||||
| 	what       Type | 	what       Type | ||||||
| 	permission types.Permission | 	permission types.Permission | ||||||
| @ -159,7 +159,7 @@ type DataSection struct { | |||||||
| // TypeSection represents a blind type definition. | // TypeSection represents a blind type definition. | ||||||
| type TypeSection struct { | type TypeSection struct { | ||||||
| 	locatable | 	locatable | ||||||
| 	name string | 	nameable | ||||||
| 	 | 	 | ||||||
| 	inherits     Type | 	inherits     Type | ||||||
| 	permission   types.Permission | 	permission   types.Permission | ||||||
| @ -169,7 +169,7 @@ type TypeSection struct { | |||||||
| // ObjtMember represents a part of an object type definition. | // ObjtMember represents a part of an object type definition. | ||||||
| type ObjtMember struct { | type ObjtMember struct { | ||||||
| 	locatable | 	locatable | ||||||
| 	name string | 	nameable | ||||||
| 
 | 
 | ||||||
| 	what         Type | 	what         Type | ||||||
| 	bitWidth     uint64 | 	bitWidth     uint64 | ||||||
| @ -180,7 +180,7 @@ type ObjtMember struct { | |||||||
| // ObjtSection represents an object type definition. | // ObjtSection represents an object type definition. | ||||||
| type ObjtSection struct { | type ObjtSection struct { | ||||||
| 	locatable | 	locatable | ||||||
| 	name string | 	nameable | ||||||
| 
 | 
 | ||||||
| 	inherits     Identifier | 	inherits     Identifier | ||||||
| 	permission   types.Permission | 	permission   types.Permission | ||||||
| @ -190,14 +190,14 @@ type ObjtSection struct { | |||||||
| // EnumMember represents a member of an enum section. | // EnumMember represents a member of an enum section. | ||||||
| type EnumMember struct { | type EnumMember struct { | ||||||
| 	locatable | 	locatable | ||||||
| 	name  string | 	nameable | ||||||
| 	value Argument | 	value Argument | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // EnumSection represents an enumerated type section. | // EnumSection represents an enumerated type section. | ||||||
| type EnumSection struct { | type EnumSection struct { | ||||||
| 	locatable | 	locatable | ||||||
| 	name string | 	nameable | ||||||
| 	 | 	 | ||||||
| 	what       Type | 	what       Type | ||||||
| 	permission types.Permission | 	permission types.Permission | ||||||
| @ -207,7 +207,7 @@ type EnumSection struct { | |||||||
| // FaceBehavior represents a behavior of an interface section. | // FaceBehavior represents a behavior of an interface section. | ||||||
| type FaceBehavior struct { | type FaceBehavior struct { | ||||||
| 	locatable | 	locatable | ||||||
| 	name string | 	nameable | ||||||
| 
 | 
 | ||||||
| 	inputs  []Declaration | 	inputs  []Declaration | ||||||
| 	outputs []Declaration | 	outputs []Declaration | ||||||
| @ -216,7 +216,7 @@ type FaceBehavior struct { | |||||||
| // FaceSection represents an interface type section. | // FaceSection represents an interface type section. | ||||||
| type FaceSection struct { | type FaceSection struct { | ||||||
| 	locatable | 	locatable | ||||||
| 	name     string | 	nameable | ||||||
| 	inherits Identifier | 	inherits Identifier | ||||||
| 	 | 	 | ||||||
| 	permission types.Permission | 	permission types.Permission | ||||||
| @ -269,7 +269,7 @@ type FuncOutput struct { | |||||||
| // FuncSection represents a function section. | // FuncSection represents a function section. | ||||||
| type FuncSection struct { | type FuncSection struct { | ||||||
| 	locatable | 	locatable | ||||||
| 	name       string | 	nameable | ||||||
| 	permission types.Permission | 	permission types.Permission | ||||||
| 	 | 	 | ||||||
| 	receiver *Declaration | 	receiver *Declaration | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user