Commit 29be2982 by Andrew Dahl

Minor flex additions to treat multiple newlines in a row as one and a new token…

Minor flex additions to treat multiple newlines in a row as one and a new token that ignores all types of whitespace around curly braces
parent 8ce92a59
Showing with 19 additions and 15 deletions
......@@ -69,22 +69,14 @@ function_define: function_decl argument_exp_list RPAREN EQUALS additive_exp NEWL
instructions->levelPop();
$$ = $1;
}
| function_decl argument_exp_list RPAREN left_curly statlist RETURN additive_exp right_curly {
| function_decl argument_exp_list RPAREN LCURLY statlist RETURN additive_exp RCURLY {
$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));
......
......@@ -32,8 +32,9 @@ extern YYSTYPE yylval;
%option noyywrap
delim [ \t]
newline [\n]
newline [\n]+
whitesp {delim}+
whiteall ({whitesp}|{newline})?*
digit [0-9]
nonzeronumber [1-9]{digit}*
zero [0]
......@@ -46,8 +47,8 @@ slash [/]
equals [=]
lparen [(]
rparen [)]
lcurly [{]
rcurly [}]
lcurly {whiteall}?[{]{whiteall}?
rcurly {whiteall}?[}]{whiteall}?
letter [a-zA-Z]
identifier {letter}({letter}|{digit})*
comma [,]
......
......@@ -4,11 +4,22 @@ 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){
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