Phrases in functions are now ToString'd
This commit is contained in:
		
							parent
							
								
									eee50dc9b0
								
							
						
					
					
						commit
						dbbe0198d5
					
				| @ -48,7 +48,7 @@ func (parser *ParsingOperation) parseArgument () (argument Argument, err error) | |||||||
| 			} | 			} | ||||||
| 		} else { | 		} else { | ||||||
| 			argument.kind  = ArgumentKindIdentifier | 			argument.kind  = ArgumentKindIdentifier | ||||||
| 			argument.value = identifier | 			argument.value = &identifier | ||||||
| 		} | 		} | ||||||
| 		 | 		 | ||||||
| 	case lexer.TokenKindInt: | 	case lexer.TokenKindInt: | ||||||
| @ -78,9 +78,12 @@ func (parser *ParsingOperation) parseArgument () (argument Argument, err error) | |||||||
| 		 | 		 | ||||||
| 	case lexer.TokenKindLBracket: | 	case lexer.TokenKindLBracket: | ||||||
| 		argument.kind = ArgumentKindPhrase | 		argument.kind = ArgumentKindPhrase | ||||||
| 		argument.value, err = parser.parseArgumentLevelPhrase() | 		var phrase Phrase | ||||||
|  | 		phrase, err = parser.parseArgumentLevelPhrase() | ||||||
|  | 		argument.value = &phrase | ||||||
| 		parser.nextToken() | 		parser.nextToken() | ||||||
| 		 | 		 | ||||||
|  | 
 | ||||||
| 	default: | 	default: | ||||||
| 		panic ( | 		panic ( | ||||||
| 			"unimplemented argument kind " + | 			"unimplemented argument kind " + | ||||||
|  | |||||||
| @ -153,24 +153,15 @@ func (values *ArrayInitializationValues) ToString ( | |||||||
| 	return | 	return | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (phrase *Phrase) ToString (indent int, breakLine bool) (output string) { | func (phrase *Phrase) ToString (indent int, ownLine bool) (output string) { | ||||||
| 	if breakLine { | 	if ownLine { | ||||||
| 		output += doIndent ( | 		output += doIndent(indent) | ||||||
| 			indent, |  | ||||||
| 			"[", phrase.command.ToString(0, false)) |  | ||||||
| 		output += "\n" |  | ||||||
| 		for _, argument := range phrase.arguments { |  | ||||||
| 			output += doIndent ( |  | ||||||
| 				indent, |  | ||||||
| 				argument.ToString(indent + 1, true)) |  | ||||||
| 	} | 	} | ||||||
| 	} else { | 	 | ||||||
| 	output += "[" + phrase.command.ToString(0, false) | 	output += "[" + phrase.command.ToString(0, false) | ||||||
| 	for _, argument := range phrase.arguments { | 	for _, argument := range phrase.arguments { | ||||||
| 		output += " " + argument.ToString(0, false) | 		output += " " + argument.ToString(0, false) | ||||||
| 	} | 	} | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	output += "]" | 	output += "]" | ||||||
| 
 | 
 | ||||||
| 	if len(phrase.returnsTo) > 0 { | 	if len(phrase.returnsTo) > 0 { | ||||||
| @ -180,7 +171,7 @@ func (phrase *Phrase) ToString (indent int, breakLine bool) (output string) { | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if breakLine { | 	if ownLine { | ||||||
| 		output += "\n" | 		output += "\n" | ||||||
| 	} | 	} | ||||||
| 	return | 	return | ||||||
| @ -395,6 +386,14 @@ func (behavior *FaceBehavior) ToString (indent int) (output string) { | |||||||
| 	return | 	return | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | func (block Block) ToString (indent int) (output string) { | ||||||
|  | 	for _, phrase := range block { | ||||||
|  | 		output += phrase.ToString(indent, true) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	return | ||||||
|  | } | ||||||
|  | 
 | ||||||
| func (section *FuncSection) ToString (indent int) (output string) { | func (section *FuncSection) ToString (indent int) (output string) { | ||||||
| 	output += doIndent ( | 	output += doIndent ( | ||||||
| 		indent, | 		indent, | ||||||
| @ -422,7 +421,6 @@ func (section *FuncSection) ToString (indent int) (output string) { | |||||||
| 		output += doIndent(indent + 1, "external\n") | 		output += doIndent(indent + 1, "external\n") | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	// TODO: print out root block | 	output += section.root.ToString(indent + 1) | ||||||
| 
 |  | ||||||
| 	return | 	return | ||||||
| } | } | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user