Compare commits
No commits in common. "befe371e4f8b4f03b8adb081f3c2ee434be6e219" and "5641220986f584fbbdcf26793b64e789fcd02453" have entirely different histories.
befe371e4f
...
5641220986
@ -58,7 +58,7 @@ func (analyzer *analysisOperation) analyze () (err error) {
|
|||||||
for !sections.End() {
|
for !sections.End() {
|
||||||
_, err = analyzer.fetchSection(locator {
|
_, err = analyzer.fetchSection(locator {
|
||||||
modulePath: analyzer.modulePath,
|
modulePath: analyzer.modulePath,
|
||||||
name: sections.Key(),
|
name: sections.Value().Name(),
|
||||||
})
|
})
|
||||||
if err != nil { return err }
|
if err != nil { return err }
|
||||||
sections.Next()
|
sections.Next()
|
||||||
@ -93,7 +93,7 @@ func (analyzer *analysisOperation) fetchSection (
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var parsedSection = tree.LookupSection("", where.name)
|
var parsedSection = tree.LookupSection(where.name)
|
||||||
if parsedSection == nil {
|
if parsedSection == nil {
|
||||||
section = nil
|
section = nil
|
||||||
return
|
return
|
||||||
|
@ -1,31 +1,5 @@
|
|||||||
package analyzer
|
package analyzer
|
||||||
|
|
||||||
import "git.tebibyte.media/arf/arf/parser"
|
|
||||||
|
|
||||||
// Block represents a scoped block of phrases.
|
|
||||||
type Block struct {
|
type Block struct {
|
||||||
locatable
|
locatable
|
||||||
phrases []Phrase
|
|
||||||
|
|
||||||
// TODO: create a scope struct and embed it
|
|
||||||
}
|
|
||||||
|
|
||||||
func (block Block) ToString (indent int) (output string) {
|
|
||||||
output += doIndent(indent, "block\n")
|
|
||||||
|
|
||||||
// TODO: variables
|
|
||||||
// TODO: phrases
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// analyzeBlock analyzes a scoped block of phrases.
|
|
||||||
// TODO: have a way to "start out" with a list of variables for things like
|
|
||||||
// arguments, and declarations inside of control flow statements
|
|
||||||
func (analyzer *analysisOperation) analyzeBlock (
|
|
||||||
inputBlock parser.Block,
|
|
||||||
) (
|
|
||||||
block Block,
|
|
||||||
err error,
|
|
||||||
) {
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ import "git.tebibyte.media/arf/arf/infoerr"
|
|||||||
// FuncSection represents a type definition section.
|
// FuncSection represents a type definition section.
|
||||||
type FuncSection struct {
|
type FuncSection struct {
|
||||||
sectionBase
|
sectionBase
|
||||||
root Block
|
|
||||||
external bool
|
external bool
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19,7 +18,7 @@ func (section FuncSection) ToString (indent int) (output string) {
|
|||||||
output += "\n"
|
output += "\n"
|
||||||
|
|
||||||
// TODO: arguments
|
// TODO: arguments
|
||||||
output += section.root.ToString(indent + 1)
|
// TODO: root block
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,8 +53,6 @@ func (analyzer *analysisOperation) analyzeFuncSection () (
|
|||||||
outputSection.external = true
|
outputSection.external = true
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
outputSection.root, err = analyzer.analyzeBlock(inputSection.Root())
|
|
||||||
if err != nil { return }
|
|
||||||
// TODO: analyze root block if not nil
|
// TODO: analyze root block if not nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,17 +3,8 @@ package parser
|
|||||||
import "git.tebibyte.media/arf/arf/types"
|
import "git.tebibyte.media/arf/arf/types"
|
||||||
|
|
||||||
// LookupSection looks returns the section under the give name. If the section
|
// LookupSection looks returns the section under the give name. If the section
|
||||||
// does not exist, nil is returned. If a method is being searched for, the type
|
// does not exist, nil is returned.
|
||||||
// name of its receiver should be passed. If not, it should just be left blank.
|
func (tree SyntaxTree) LookupSection (name string) (section Section) {
|
||||||
func (tree SyntaxTree) LookupSection (
|
|
||||||
receiver string,
|
|
||||||
name string,
|
|
||||||
) (
|
|
||||||
section Section,
|
|
||||||
) {
|
|
||||||
if receiver != "" {
|
|
||||||
name = receiver + "_" + name
|
|
||||||
}
|
|
||||||
section = tree.sections[name]
|
section = tree.sections[name]
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -53,17 +53,7 @@ func (parser *parsingOperation) parseBody () (err error) {
|
|||||||
// addSection adds a section to the tree, ensuring it has a unique name within
|
// addSection adds a section to the tree, ensuring it has a unique name within
|
||||||
// the module.
|
// the module.
|
||||||
func (tree *SyntaxTree) addSection (section Section) (err error) {
|
func (tree *SyntaxTree) addSection (section Section) (err error) {
|
||||||
index := section.Name()
|
_, exists := tree.sections[section.Name()]
|
||||||
|
|
||||||
funcSection, isFuncSection := section.(FuncSection)
|
|
||||||
if isFuncSection {
|
|
||||||
receiver := funcSection.receiver
|
|
||||||
if receiver != nil {
|
|
||||||
index = receiver.what.points.name.trail[0] + "_" + index
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_, exists := tree.sections[index]
|
|
||||||
if exists {
|
if exists {
|
||||||
err = section.NewError (
|
err = section.NewError (
|
||||||
"cannot have multiple sections with the same name",
|
"cannot have multiple sections with the same name",
|
||||||
@ -71,6 +61,6 @@ func (tree *SyntaxTree) addSection (section Section) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tree.sections[index] = section
|
tree.sections[section.Name()] = section
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -6,13 +6,13 @@ func TestFunc (test *testing.T) {
|
|||||||
checkTree ("../tests/parser/func", false,
|
checkTree ("../tests/parser/func", false,
|
||||||
`:arf
|
`:arf
|
||||||
---
|
---
|
||||||
func ro bMethod
|
func ro aBasicExternal
|
||||||
@ bird:{Bird}
|
|
||||||
> someInput:Int:mut
|
> someInput:Int:mut
|
||||||
< someOutput:Int 4
|
< someOutput:Int 4
|
||||||
---
|
---
|
||||||
external
|
external
|
||||||
func ro aBasicExternal
|
func ro bMethod
|
||||||
|
@ bird:{Bird}
|
||||||
> someInput:Int:mut
|
> someInput:Int:mut
|
||||||
< someOutput:Int 4
|
< someOutput:Int 4
|
||||||
---
|
---
|
||||||
|
Reference in New Issue
Block a user