Analyzer attempts to find the source of types
This commit is contained in:
		
							parent
							
								
									1300f87cb5
								
							
						
					
					
						commit
						d117e2727c
					
				@ -127,13 +127,12 @@ func (analyzer *AnalysisOperation) fetchSectionFromIdentifier (
 | 
				
			|||||||
	bitten  parser.Identifier,
 | 
						bitten  parser.Identifier,
 | 
				
			||||||
	err     error,
 | 
						err     error,
 | 
				
			||||||
) {
 | 
					) {
 | 
				
			||||||
	bitten = which
 | 
						item, bitten := which.Bite()
 | 
				
			||||||
	item := bitten.Bite()
 | 
					 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	path, exists := analyzer.currentTree.ResolveRequire(item)
 | 
						path, exists := analyzer.currentTree.ResolveRequire(item)
 | 
				
			||||||
	if exists {
 | 
						if exists {
 | 
				
			||||||
		// we have our module path, so get the section name
 | 
							// we have our module path, so get the section name
 | 
				
			||||||
		item = bitten.Bite()
 | 
							item, bitten = bitten.Bite()
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		// that wasn't a module name, so the module path must be the our
 | 
							// that wasn't a module name, so the module path must be the our
 | 
				
			||||||
		// current one
 | 
							// current one
 | 
				
			||||||
 | 
				
			|||||||
@ -52,7 +52,8 @@ func (analyzer AnalysisOperation) analyzeTypeSection () (
 | 
				
			|||||||
) {
 | 
					) {
 | 
				
			||||||
	outputSection := TypeSection { }
 | 
						outputSection := TypeSection { }
 | 
				
			||||||
	outputSection.where = analyzer.currentPosition
 | 
						outputSection.where = analyzer.currentPosition
 | 
				
			||||||
	section = outputSection
 | 
					
 | 
				
			||||||
 | 
						section = &outputSection
 | 
				
			||||||
	analyzer.addSection(section)
 | 
						analyzer.addSection(section)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	inputSection := analyzer.currentSection.(parser.TypeSection)
 | 
						inputSection := analyzer.currentSection.(parser.TypeSection)
 | 
				
			||||||
@ -66,6 +67,9 @@ func (analyzer AnalysisOperation) analyzeTypeSection () (
 | 
				
			|||||||
	outputSection.what, err = analyzer.analyzeType(inputSection.Type())
 | 
						outputSection.what, err = analyzer.analyzeType(inputSection.Type())
 | 
				
			||||||
	if err != nil { return }
 | 
						if err != nil { return }
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// TODO: analyze members
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	outputSection.complete = true
 | 
						outputSection.complete = true
 | 
				
			||||||
	return
 | 
						return
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -89,6 +89,18 @@ func (analyzer AnalysisOperation) analyzeType (
 | 
				
			|||||||
		var points Type
 | 
							var points Type
 | 
				
			||||||
		points, err = analyzer.analyzeType(inputType.Points())
 | 
							points, err = analyzer.analyzeType(inputType.Points())
 | 
				
			||||||
		outputType.points = &points
 | 
							outputType.points = &points
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							var bitten parser.Identifier
 | 
				
			||||||
 | 
							outputType.actual,
 | 
				
			||||||
 | 
							bitten,
 | 
				
			||||||
 | 
							err = analyzer.fetchSectionFromIdentifier(inputType.Name())
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							if bitten.Length() > 0 {
 | 
				
			||||||
 | 
								err = bitten.NewError(
 | 
				
			||||||
 | 
									"cannot use member selection in this context",
 | 
				
			||||||
 | 
									infoerr.ErrorKindError)
 | 
				
			||||||
 | 
								return
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	// TODO
 | 
						// TODO
 | 
				
			||||||
 | 
				
			|||||||
@ -35,10 +35,17 @@ func (identifier Identifier) Item (index int) (item string) {
 | 
				
			|||||||
	return
 | 
						return
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Bite removes the first item from the identifier and returns it.
 | 
					// Bite returns the first item of an identifier, and a copy of that identifier
 | 
				
			||||||
func (identifier *Identifier) Bite () (item string) {
 | 
					// with that item removed. If there is nothing left to bite off, this method
 | 
				
			||||||
	item = identifier.trail[0]
 | 
					// panics.
 | 
				
			||||||
	identifier.trail = identifier.trail[1:]
 | 
					func (identifier Identifier) Bite () (item string, bitten Identifier) {
 | 
				
			||||||
 | 
						if len(identifier.trail) < 1 {
 | 
				
			||||||
 | 
							panic ("trying to bite an empty identifier")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						bitten = identifier
 | 
				
			||||||
 | 
						item = bitten.trail[0]
 | 
				
			||||||
 | 
						bitten.trail = bitten.trail[1:]
 | 
				
			||||||
	return
 | 
						return
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user