29 lines
714 B
Go
29 lines
714 B
Go
package analyzer
|
|
|
|
// import "fmt"
|
|
//import "github.com/alecthomas/participle/v2"
|
|
import "git.tebibyte.media/sashakoshka/fspl/entity"
|
|
|
|
func (this *Tree) analyzeAssignment (
|
|
assignment *entity.Assignment,
|
|
) (
|
|
entity.Statement,
|
|
error,
|
|
) {
|
|
// analyze location
|
|
location, err := this.analyzeExpression(nil, strict, assignment.Location)
|
|
if err != nil { return nil, err }
|
|
assignment.Location = location
|
|
|
|
// ensure location is location expression
|
|
err = this.isLocationExpression(location)
|
|
if err != nil { return nil, err }
|
|
|
|
// analyze value
|
|
value, err := this.analyzeExpression(location.Type(), strict, assignment.Value)
|
|
if err != nil { return nil, err }
|
|
assignment.Value = value
|
|
|
|
return assignment, nil
|
|
}
|