diff options
author | Paweł Dybiec <pdybiec@stud.cs.uni.wroc.pl> | 2018-11-04 15:07:47 +0100 |
---|---|---|
committer | Paweł Dybiec <pdybiec@stud.cs.uni.wroc.pl> | 2018-11-04 15:07:47 +0100 |
commit | d8b0263cf9fc8819c2c016879ba23c0939b41201 (patch) | |
tree | 1b37295f9bf7129fb5e2d7ca3ed3f91331ac7302 /source/mod_student | |
parent | parse function arguments (diff) |
Parse array dimensions
Diffstat (limited to 'source/mod_student')
-rw-r--r-- | source/mod_student/parser.mly | 10 |
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 } |