Compare commits

..

No commits in common. "11969428018f479d3d54eb931d62d314f6f063d5" and "877f85ef782b16fc253c0cb1c48108f505672e27" have entirely different histories.

2 changed files with 41 additions and 48 deletions

1
ast.go
View File

@ -115,7 +115,6 @@ func executeCmd(cmd *Command) error {
} }
} }
} }
delete(Vars, *RptLoop.IndexVar)
} }
} }
return nil return nil

16
scpt.go
View File

@ -98,24 +98,16 @@ func ParseValue(val *Value) (interface{}, error) {
// Return value of provided key // Return value of provided key
return Vars[*val.VarVal], nil return Vars[*val.VarVal], nil
} else if val.Expr != nil { } else if val.Expr != nil {
// Return evaluated expression
return evalExpr(*val.Expr)
}
return nil, nil
}
// Evaluate given expression, returning its value and optionally an error
func evalExpr(expression Expression) (interface{}, error) {
// Parse value of left side of expression // Parse value of left side of expression
left, _ := callIfFunc(ParseValue(expression.Left)) left, _ := callIfFunc(ParseValue(val.Expr.Left))
// If value is string, requote // If value is string, requote
if isStr(left) { if isStr(left) {
left = requoteStr(left.(string)) left = requoteStr(left.(string))
} }
// Create new nil string // Create new nil string
var right string var right string
// For every right gsegment // For every right segment
for _, segment := range expression.RightSegs { for _, segment := range val.Expr.RightSegs {
// Parse value of right segment, calling it if it is a function // Parse value of right segment, calling it if it is a function
rVal, _ := callIfFunc(ParseValue(segment.Right)) rVal, _ := callIfFunc(ParseValue(segment.Right))
// If value is string, requote // If value is string, requote
@ -148,6 +140,8 @@ func evalExpr(expression Expression) (interface{}, error) {
// Return expression output value // Return expression output value
return out, nil return out, nil
} }
return nil, nil
}
// Add quotes to an unquoted string // Add quotes to an unquoted string
func requoteStr(s string) string { func requoteStr(s string) string {