summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--source/mod_student/parser.mly10
1 files changed, 6 insertions, 4 deletions
diff --git a/source/mod_student/parser.mly b/source/mod_student/parser.mly
index 0fb4ee0..c031383 100644
--- a/source/mod_student/parser.mly
+++ b/source/mod_student/parser.mly
@@ -82,20 +82,22 @@ file:
 
 func:
     | id=identifier LPAREN parameters=list(argument) RPAREN 
-    { GDECL_Function { loc=Location( {line=0;column=0;file=""});
+    { GDECL_Function { loc=mkLocation $startpos;
     id=id;formal_parameters=parameters; return_types=[];body=None} }
 argument:
     | id = identifier COLON t=typ 
     { VarDecl {loc=mkLocation $startpos;id=id;tp=t} }
 typ:
     | t=base_type { t }
-    | t=typ LSBRACKET option(INT) RSBRACKET 
+    | t=typ LSBRACKET dim=option(expression) RSBRACKET 
       { TEXPR_Array { loc=mkLocation $startpos;
-        sub=t;dim=None } }
+        sub=t;dim=dim } }
 base_type:
     | T_INT  {TEXPR_Int {loc=mkLocation $startpos}}
     | T_BOOL {TEXPR_Bool {loc=mkLocation $startpos}}
-
+expression:
+    | value=INT  { EXPR_Int {tag= mkTag ();loc=mkLocation $startpos;
+                              value=Int32.of_int value} }
 identifier:
     |  IDENTIFIER
     { Identifier $1 }