Less gooooo!
This commit is contained in:
parent
ed4c9aa0d2
commit
bb4a5472e1
@ -157,6 +157,20 @@ func (analyzer *AnalysisOperation) fetchSectionFromIdentifier (
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// addSection adds a section to the analyzer's section table. If a section with
|
||||||
|
// that name already exists, it panics because the parser should not have given
|
||||||
|
// that to us.
|
||||||
|
func (analyzer *AnalysisOperation) addSection (section Section) {
|
||||||
|
_, exists := analyzer.sectionTable[section.locator()]
|
||||||
|
if exists {
|
||||||
|
panic (
|
||||||
|
"invalid state: duplicate section " +
|
||||||
|
section.locator().ToString())
|
||||||
|
}
|
||||||
|
analyzer.sectionTable[section.locator()] = section
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func doIndent (indent int, input ...any) (output string) {
|
func doIndent (indent int, input ...any) (output string) {
|
||||||
for index := 0; index < indent; index ++ {
|
for index := 0; index < indent; index ++ {
|
||||||
output += "\t"
|
output += "\t"
|
||||||
|
@ -33,6 +33,7 @@ type Section interface {
|
|||||||
Complete () (complete bool)
|
Complete () (complete bool)
|
||||||
ModulePath () (path string)
|
ModulePath () (path string)
|
||||||
ModuleName () (path string)
|
ModuleName () (path string)
|
||||||
|
locator () (where locator)
|
||||||
|
|
||||||
// Must be implemented by each individual section
|
// Must be implemented by each individual section
|
||||||
ToString (indent int) (output string)
|
ToString (indent int) (output string)
|
||||||
@ -67,3 +68,8 @@ func (section sectionBase) Complete () (complete bool) {
|
|||||||
complete = section.complete
|
complete = section.complete
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (section sectionBase) locator () (where locator) {
|
||||||
|
where = section.where
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@ -50,6 +50,11 @@ func (analyzer AnalysisOperation) analyzeTypeSection () (
|
|||||||
section Section,
|
section Section,
|
||||||
err error,
|
err error,
|
||||||
) {
|
) {
|
||||||
|
outputSection := TypeSection { }
|
||||||
|
outputSection.where = analyzer.currentPosition
|
||||||
|
section = outputSection
|
||||||
|
analyzer.addSection(section)
|
||||||
|
|
||||||
inputSection := analyzer.currentSection.(parser.TypeSection)
|
inputSection := analyzer.currentSection.(parser.TypeSection)
|
||||||
if inputSection.Permission() == types.PermissionReadWrite {
|
if inputSection.Permission() == types.PermissionReadWrite {
|
||||||
err = inputSection.NewError (
|
err = inputSection.NewError (
|
||||||
@ -58,9 +63,6 @@ func (analyzer AnalysisOperation) analyzeTypeSection () (
|
|||||||
infoerr.ErrorKindError)
|
infoerr.ErrorKindError)
|
||||||
}
|
}
|
||||||
|
|
||||||
outputSection := TypeSection { }
|
|
||||||
outputSection.where = analyzer.currentPosition
|
|
||||||
|
|
||||||
outputSection.what, err = analyzer.analyzeType(inputSection.Type())
|
outputSection.what, err = analyzer.analyzeType(inputSection.Type())
|
||||||
if err != nil { return }
|
if err != nil { return }
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ func (analyzer AnalysisOperation) analyzeType (
|
|||||||
err error,
|
err error,
|
||||||
) {
|
) {
|
||||||
outputType.mutable = inputType.Mutable()
|
outputType.mutable = inputType.Mutable()
|
||||||
if outputType.length < 1 {
|
if inputType.Length() < 1 {
|
||||||
err = inputType.NewError (
|
err = inputType.NewError (
|
||||||
"cannot specify a length of zero",
|
"cannot specify a length of zero",
|
||||||
infoerr.ErrorKindError)
|
infoerr.ErrorKindError)
|
||||||
|
Reference in New Issue
Block a user