Did the same thing with default values
This commit is contained in:
		
							parent
							
								
									e0a04e68e3
								
							
						
					
					
						commit
						899f4815bc
					
				| @ -186,12 +186,12 @@ func (parser *ParsingOperation) parseFuncArguments ( | |||||||
| 				err = parser.nextToken() | 				err = parser.nextToken() | ||||||
| 				if err != nil { return } | 				if err != nil { return } | ||||||
| 
 | 
 | ||||||
| 				output.defaultValue, err = | 				output.value, err = | ||||||
| 					parser.parseInitializationValues(1) | 					parser.parseInitializationValues(1) | ||||||
| 				into.outputs = append(into.outputs, output) | 				into.outputs = append(into.outputs, output) | ||||||
| 				if err != nil { return } | 				if err != nil { return } | ||||||
| 			} else { | 			} else { | ||||||
| 				output.defaultValue, err = | 				output.value, err = | ||||||
| 					parser.parseArgument() | 					parser.parseArgument() | ||||||
| 				into.outputs = append(into.outputs, output) | 				into.outputs = append(into.outputs, output) | ||||||
| 				if err != nil { return } | 				if err != nil { return } | ||||||
|  | |||||||
| @ -52,7 +52,19 @@ type permissionable struct { | |||||||
| 	permission types.Permission | 	permission types.Permission | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // Permission returns the permision of the node. | ||||||
| func (trait permissionable) Permission () (permission types.Permission) { | func (trait permissionable) Permission () (permission types.Permission) { | ||||||
| 	permission = trait.permission | 	permission = trait.permission | ||||||
| 	return | 	return | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | // valuable allows a node to have an argument value. | ||||||
|  | type valuable struct { | ||||||
|  | 	value Argument | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // Value returns the value argument of the node. | ||||||
|  | func (trait valuable) Value () (value Argument) { | ||||||
|  | 	value = trait.value | ||||||
|  | 	return | ||||||
|  | } | ||||||
|  | |||||||
| @ -109,11 +109,11 @@ func (parser *ParsingOperation) parseObjtMember () ( | |||||||
| 		err = parser.nextToken() | 		err = parser.nextToken() | ||||||
| 		if err != nil { return } | 		if err != nil { return } | ||||||
| 
 | 
 | ||||||
| 		member.defaultValue, | 		member.value, | ||||||
| 		err = parser.parseInitializationValues(1) | 		err = parser.parseInitializationValues(1) | ||||||
| 		if err != nil { return } | 		if err != nil { return } | ||||||
| 	} else { | 	} else { | ||||||
| 		member.defaultValue, err = parser.parseArgument() | 		member.value, err = parser.parseArgument() | ||||||
| 		if err != nil { return } | 		if err != nil { return } | ||||||
| 
 | 
 | ||||||
| 		err = parser.expect(lexer.TokenKindNewline) | 		err = parser.expect(lexer.TokenKindNewline) | ||||||
|  | |||||||
| @ -312,16 +312,16 @@ func (section *TypeSection) ToString (indent int) (output string) { | |||||||
| 		section.what.ToString()) | 		section.what.ToString()) | ||||||
| 
 | 
 | ||||||
| 	isComplexInitialization := | 	isComplexInitialization := | ||||||
| 		section.defaultValue.kind == ArgumentKindObjectInitializationValues || | 		section.value.kind == ArgumentKindObjectInitializationValues || | ||||||
| 		section.defaultValue.kind == ArgumentKindArrayInitializationValues | 		section.value.kind == ArgumentKindArrayInitializationValues | ||||||
| 
 | 
 | ||||||
| 	if section.defaultValue.value == nil { | 	if section.value.value == nil { | ||||||
| 		output += "\n" | 		output += "\n" | ||||||
| 	} else if isComplexInitialization { | 	} else if isComplexInitialization { | ||||||
| 		output += "\n" | 		output += "\n" | ||||||
| 		output += section.defaultValue.ToString(indent + 1, true) | 		output += section.value.ToString(indent + 1, true) | ||||||
| 	} else { | 	} else { | ||||||
| 		output += " " + section.defaultValue.ToString(0, false) | 		output += " " + section.value.ToString(0, false) | ||||||
| 		output += "\n" | 		output += "\n" | ||||||
| 	} | 	} | ||||||
| 	return | 	return | ||||||
| @ -339,16 +339,16 @@ func (member ObjtMember) ToString (indent int) (output string) { | |||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	isComplexInitialization := | 	isComplexInitialization := | ||||||
| 		member.defaultValue.kind == ArgumentKindObjectInitializationValues || | 		member.value.kind == ArgumentKindObjectInitializationValues || | ||||||
| 		member.defaultValue.kind == ArgumentKindArrayInitializationValues | 		member.value.kind == ArgumentKindArrayInitializationValues | ||||||
| 	 | 	 | ||||||
| 	if member.defaultValue.value == nil { | 	if member.value.value == nil { | ||||||
| 		output += "\n" | 		output += "\n" | ||||||
| 	} else if isComplexInitialization { | 	} else if isComplexInitialization { | ||||||
| 		output += "\n" | 		output += "\n" | ||||||
| 		output += member.defaultValue.ToString(indent + 1, true) | 		output += member.value.ToString(indent + 1, true) | ||||||
| 	} else { | 	} else { | ||||||
| 		output += " " + member.defaultValue.ToString(0, false) | 		output += " " + member.value.ToString(0, false) | ||||||
| 		output += "\n" | 		output += "\n" | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| @ -473,8 +473,8 @@ func (block Block) ToString (indent int) (output string) { | |||||||
| 
 | 
 | ||||||
| func (funcOutput FuncOutput) ToString () (output string) { | func (funcOutput FuncOutput) ToString () (output string) { | ||||||
| 	output += funcOutput.Declaration.ToString() | 	output += funcOutput.Declaration.ToString() | ||||||
| 	if funcOutput.defaultValue.kind != ArgumentKindNil { | 	if funcOutput.value.kind != ArgumentKindNil { | ||||||
| 		output += " " + funcOutput.defaultValue.ToString(0, false) | 		output += " " + funcOutput.value.ToString(0, false) | ||||||
| 	} | 	} | ||||||
| 	return | 	return | ||||||
| } | } | ||||||
|  | |||||||
| @ -161,8 +161,7 @@ type TypeSection struct { | |||||||
| 	nameable | 	nameable | ||||||
| 	typeable | 	typeable | ||||||
| 	permissionable | 	permissionable | ||||||
| 	 | 	valuable | ||||||
| 	defaultValue Argument |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // ObjtMember represents a part of an object type definition. | // ObjtMember represents a part of an object type definition. | ||||||
| @ -171,9 +170,9 @@ type ObjtMember struct { | |||||||
| 	nameable | 	nameable | ||||||
| 	typeable | 	typeable | ||||||
| 	permissionable | 	permissionable | ||||||
|  | 	valuable | ||||||
| 	 | 	 | ||||||
| 	bitWidth     uint64 | 	bitWidth     uint64 | ||||||
| 	defaultValue Argument |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // ObjtSection represents an object type definition. | // ObjtSection represents an object type definition. | ||||||
| @ -190,7 +189,7 @@ type ObjtSection struct { | |||||||
| type EnumMember struct { | type EnumMember struct { | ||||||
| 	locatable | 	locatable | ||||||
| 	nameable | 	nameable | ||||||
| 	value Argument | 	valuable | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // EnumSection represents an enumerated type section. | // EnumSection represents an enumerated type section. | ||||||
| @ -262,7 +261,7 @@ type Block []Phrase | |||||||
| // that it can have a default value. | // that it can have a default value. | ||||||
| type FuncOutput struct { | type FuncOutput struct { | ||||||
| 	Declaration | 	Declaration | ||||||
| 	defaultValue Argument | 	valuable | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // FuncSection represents a function section. | // FuncSection represents a function section. | ||||||
|  | |||||||
| @ -38,10 +38,10 @@ func (parser *ParsingOperation) parseTypeSection () ( | |||||||
| 		err = parser.nextToken() | 		err = parser.nextToken() | ||||||
| 		if err != nil { return } | 		if err != nil { return } | ||||||
| 
 | 
 | ||||||
| 		section.defaultValue, err = parser.parseInitializationValues(0) | 		section.value, err = parser.parseInitializationValues(0) | ||||||
| 		if err != nil { return } | 		if err != nil { return } | ||||||
| 	} else { | 	} else { | ||||||
| 		section.defaultValue, err = parser.parseArgument() | 		section.value, err = parser.parseArgument() | ||||||
| 		if err != nil { return } | 		if err != nil { return } | ||||||
| 
 | 
 | ||||||
| 		err = parser.expect(lexer.TokenKindNewline) | 		err = parser.expect(lexer.TokenKindNewline) | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user