diff --git a/src/som/primitives/StringPrimitives.java b/src/som/primitives/StringPrimitives.java index a5e34fe..f05af02 100644 --- a/src/som/primitives/StringPrimitives.java +++ b/src/som/primitives/StringPrimitives.java @@ -118,5 +118,43 @@ public void invoke(final Frame frame, final Interpreter interpreter) { } }); + installInstancePrimitive(new SPrimitive("isWhiteSpace", universe) { + + @Override + public void invoke(final Frame frame, final Interpreter interpreter) { + SString self = (SString) frame.pop(); + if (Character.isWhitespace(self.getEmbeddedString().charAt(0))) { + frame.push(universe.trueObject); + } else { + frame.push(universe.falseObject); + } + } + }); + + installInstancePrimitive(new SPrimitive("isLetter", universe) { + + @Override + public void invoke(final Frame frame, final Interpreter interpreter) { + SString self = (SString) frame.pop(); + if (Character.isLetter(self.getEmbeddedString().charAt(0))) { + frame.push(universe.trueObject); + } else { + frame.push(universe.falseObject); + } + } + }); + + installInstancePrimitive(new SPrimitive("isDigit", universe) { + + @Override + public void invoke(final Frame frame, final Interpreter interpreter) { + SString self = (SString) frame.pop(); + if (Character.isDigit(self.getEmbeddedString().charAt(0))) { + frame.push(universe.trueObject); + } else { + frame.push(universe.falseObject); + } + } + }); } }