Something like this is sufficient as a proof of concept:
git diff eval/eval.go
diff --git a/eval/eval.go b/eval/eval.go
index 1cae1b0..694b05d 100644
--- a/eval/eval.go
+++ b/eval/eval.go
@@ -98,10 +98,17 @@ func (ev *Eval) atom(token string) primitive.Primitive {
case "nil":
return primitive.Nil{}
}
+
+ // string
if token[0] == '"' {
return primitive.String(strings.ReplaceAll(strings.Trim(token, `"`), `\"`, `"`))
}
+ // character literal
+ if strings.HasPrefix(token,"#\\") {
+ return primitive.String( token[2:] )
+ }
+
// if it isn't a number then it is a symbol
f, err := strconv.ParseFloat(token, 64)
if err == nil {
Once that is done we should obviously have "primitive.Char(acter)", and implement some character primitives:
char=
char/=
char<
char>
char<=
char>=
And probably look at some kinda way to split a string into characters, and vice versa. (split) is used for that right now, but it officially returns strings - and I just split into characters via an empty second argument
Something like this is sufficient as a proof of concept:
Once that is done we should obviously have "primitive.Char(acter)", and implement some character primitives:
And probably look at some kinda way to split a string into characters, and vice versa. (split) is used for that right now, but it officially returns strings - and I just split into characters via an empty second argument