[vala] Genie: Support array and string slices



commit c10644829f9509c84e12f62f5da0894c55d54576
Author: Jamie McCracken <jamie.mccrack gmail com>
Date:   Mon May 24 14:21:18 2010 -0400

    Genie: Support array and string slices

 vala/valagenieparser.vala |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/vala/valagenieparser.vala b/vala/valagenieparser.vala
index 3a25d6b..76e057e 100644
--- a/vala/valagenieparser.vala
+++ b/vala/valagenieparser.vala
@@ -897,13 +897,22 @@ public class Vala.Genie.Parser : CodeVisitor {
 	Expression parse_element_access (SourceLocation begin, Expression inner) throws ParseError {
 		expect (TokenType.OPEN_BRACKET);
 		var index_list = parse_expression_list ();
+		Expression? stop = null;
+		if (index_list.size == 1 && accept (TokenType.COLON)) {
+			// slice expression
+			stop = parse_expression ();
+		}
 		expect (TokenType.CLOSE_BRACKET);
 
-		var expr = new ElementAccess (inner, get_src (begin));
-		foreach (Expression index in index_list) {
-			expr.append_index (index);
+		if (stop == null) {
+			var expr = new ElementAccess (inner, get_src (begin));
+			foreach (Expression index in index_list) {
+				expr.append_index (index);
+			}
+			return expr;
+		} else {
+			return new SliceExpression (inner, index_list[0], stop, get_src (begin));
 		}
-		return expr;
 	}
 
 	List<Expression> parse_expression_list () throws ParseError {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]