Sequence: Support indexing into strings.
M src/main/java/nl/grauw/glass/expressions/Index.java +10 -3
@@ 25,10 25,17 @@ public class Index extends Passthrough {
 
 	@Override
 	public Expression resolve() {
-		Expression element = sequence.resolve().getElement(index.getInteger());
-		if (element == null)
+		int index = this.index.get(Type.INTEGER).getInteger();
+		Expression tail = sequence;
+		while (index > 0 && tail.is(Type.SEQUENCE)) {
+			tail = tail.get(Type.SEQUENCE).getTail();
+			index--;
+		}
+		if (index != 0)
 			return new ErrorLiteral(new EvaluationException("Index out of bounds."));
-		return element;
+		if (tail.is(Type.SEQUENCE))
+			return tail.get(Type.SEQUENCE).getHead();
+		return tail;
 	}
 
 	public String toString() {

          
M src/test/java/nl/grauw/glass/expressions/ExpressionTest.java +9 -0
@@ 307,6 307,15 @@ public class ExpressionTest extends Test
 		});
 	}
 
+	@Test
+	public void testIndexString() {
+		assertEquals('a', parse("\"abc\"[0]").getInteger());
+		assertEquals('b', parse("\"abc\"[1]").getInteger());
+		assertEquals('c', parse("\"abc\"[2]").getInteger());
+		EvaluationException e = assertThrows(EvaluationException.class, () -> { parse("\"abc\"[3]").getInteger(); });
+		assertEquals("Index out of bounds.", e.getPlainMessage());
+	}
+
 	public Expression parse(String text) {
 		return parse(text, new Scope());
 	}