CSE Machine: cannot handle binary search with loop
Closed this issue · 2 comments
martin-henz commented
https://share.sourceacademy.nus.edu.sg/0buyr
gives no response.
This variant gives a strange error in the REPL:
https://share.sourceacademy.nus.edu.sg/0buyr
martin-henz commented
The problem lies in the "else if" construct. Putting a block around the nested "if" will lead to success: https://share.sourceacademy.nus.edu.sg/emmdc
NhatMinh0208 commented
The cause is in the functions hasContinueStatement
, hasReturnStatement
and hasBreakStatement
. These functions expect a block statement and recurse into if
statements, which fails on else if
constructs since they nest an if
statement inside an if
statement.
A modification to these functions to handle this case should do.