Commit 1e146100 by Andrew Dahl

Reg #13 Made some minor improvements to the curly brace newline issue

parent 2f4e0550
Showing with 16 additions and 5 deletions
......@@ -69,14 +69,22 @@ function_define: function_decl argument_exp_list RPAREN EQUALS additive_exp NEWL
instructions->levelPop();
$$ = $1;
}
| function_decl argument_exp_list RPAREN LCURLY statlist RETURN additive_exp RCURLY {
| function_decl argument_exp_list RPAREN left_curly statlist RETURN additive_exp right_curly {
$1->setFunctionValue($2);
level = symbol_table->at(level)->getParentTable();
instructions->levelPop();
$$ = $1;
}
;
left_curly: LCURLY { }
| left_curly NEWLINE { }
;
right_curly: RCURLY { }
| NEWLINE right_curly { }
;
argument_exp_list: { $$ = NULL;}
| ID {
$$ = (symbol_table->at(level))->Insert(new Symbol($1, Symbol::VARIABLE, Symbol::INTEGER));
......@@ -96,7 +104,8 @@ assignment_exp: additive_exp
}
;
statlist: stat { }
statlist: { }
| stat { }
| statlist stat { }
;
......
......@@ -4,10 +4,12 @@ c=readInput + 2.5
function func(a,b,c,d)=a+b+c
function func2()=10
function func1(a,b)=func(a,b,1,readInput) - func2()
function outFunc(a,b,c){ output a
function outFunc(a,b,c){
output a
output b
output c
return a+b+c }
return a+b+c
}
output readInput + func(func1(readInput,a),2,func2(),0)
d=outFunc(1,2,3)
output a
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment