new operator dot '.' used to select an item or character from a list or a string respectively

This commit is contained in:
2024-04-19 09:05:26 +02:00
parent b76481bbf2
commit 7198749063
4 changed files with 71 additions and 9 deletions
+4 -5
View File
@@ -4,7 +4,6 @@
// operator-insert.go
package expr
//-------- insert term
func newInsertTerm(tk *Token) (inst *term) {
@@ -12,7 +11,7 @@ func newInsertTerm(tk *Token) (inst *term) {
tk: *tk,
children: make([]*term, 0, 2),
position: posInfix,
priority: priSign,
priority: priAssign,
evalFunc: evalInsert,
}
}
@@ -22,7 +21,7 @@ func newAppendTerm(tk *Token) (inst *term) {
tk: *tk,
children: make([]*term, 0, 2),
position: posInfix,
priority: priSign,
priority: priAssign,
evalFunc: evalAppend,
}
}
@@ -38,7 +37,7 @@ func evalInsert(ctx ExprContext, self *term) (v any, err error) {
list, _ := rightValue.([]any)
v = append([]any{leftValue}, list...)
} else {
err = self.errIncompatibleType(rightValue)
err = self.errIncompatibleTypes(leftValue, rightValue)
}
return
}
@@ -54,7 +53,7 @@ func evalAppend(ctx ExprContext, self *term) (v any, err error) {
list, _ := leftValue.([]any)
v = append(list, rightValue)
} else {
err = self.errIncompatibleType(leftValue)
err = self.errIncompatibleTypes(leftValue, rightValue)
}
return
}