summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaweł Dybiec <pdybiec@stud.cs.uni.wroc.pl>2018-11-09 00:42:27 +0100
committerPaweł Dybiec <pdybiec@stud.cs.uni.wroc.pl>2018-11-09 00:42:27 +0100
commite3d32fdd138c57fdc7447bf7bc5a7b45acdfe4aa (patch)
tree6e5fd52042e545a29647f310e809c68545789c63
parent9dadd898059a3c44f225ac5c6c4e16063b7db57d (diff)
Support multiple indexing
-rw-r--r--source/mod_student/parser.mly15
1 files changed, 7 insertions, 8 deletions
diff --git a/source/mod_student/parser.mly b/source/mod_student/parser.mly
index 7949ec8..c79181e 100644
--- a/source/mod_student/parser.mly
+++ b/source/mod_student/parser.mly
@@ -142,16 +142,10 @@ expression_unary:
{EXPR_Unop {tag=mkTag ();loc=mkLocation $startpos;
op=op;sub=right } }
expression_highest_prec:
- | node=expression_index { node }
+ | node=expression_base { node }
| node=expression_call { node }
| node=expression_length { node }
-expression_index:
- | sub=expression_base index=option( delimited(LSBRACKET,expression,RSBRACKET) )
- {
- match index with
- | None -> sub
- | Some index -> EXPR_Index {tag=mkTag (); loc=mkLocation $startpos; expr=sub; index=index}
- }
+ | node=expression_index { node }
expression_base:
| node=expression_identifier { node }
| node=expression_integer { node }
@@ -160,6 +154,11 @@ expression_base:
| node=expression_bool { node }
| node=expression_struct { node }
| LPAREN node=expression RPAREN { node }
+expression_index:
+ | sub=expression_base index=delimited(LSBRACKET,expression,RSBRACKET)
+ { EXPR_Index {tag=mkTag (); loc=mkLocation $startpos; expr=sub; index=index} }
+ | sub=expression_index index=delimited(LSBRACKET,expression,RSBRACKET)
+ { EXPR_Index {tag=mkTag (); loc=mkLocation $startpos; expr=sub; index=index} }
expression_identifier:
| id=identifier { EXPR_Id {tag= mkTag ();loc=mkLocation $startpos;
id=id} }