Commit b1cf7e54 by Andrew Dahl

Added IF to Flex/Bison

parent d4e41aab
Showing with 6 additions and 0 deletions
......@@ -153,8 +153,12 @@ stat: OUTPUT additive_exp NEWLINE {
YYABORT;
}
}
| selection_stat { }
;
selection_stat: IF additive_exp THEN LCURLY stat_list RCURLY { }
;
additive_exp: additive_exp PLUS mult_exp {
instructions->addInstruction(new Instruction(Instruction::ADD));
if($1->getReturnType() == Symbol::FLOAT || $3->getReturnType() == Symbol::FLOAT)
......
......@@ -56,6 +56,8 @@ comma [,]
%%
{number} { yylval.inum = atoi(yytext); return NUMBER; }
{float} { yylval.fnum = atof(yytext); return FLOAT; }
"if" { return IF; }
"then" { return THEN;
"function" { return FUNCTION; }
"readInput" { return USERINPUT; }
"output" { return OUTPUT; }
......
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