Skip to content

Detect incomplete statements in the REPL to insert new lines

Dominic Poerio requested to merge dpoe/lfortran:auto_multi into master

This MR implements the basic infrastructure for determining statement completeness during interactive REPL use. A callback function for determining statement completeness is passed into the prompt function. Enter is added as a key press case in the prompt as opposed to looping until the user presses enter. The prompt now loops against a statement completeness bool. If enter is pressed, the statement is evaluated for completeness according to the token balance (i.e. if there are an even number of do and end do tokens, the statement is complete, but if there are more do's than end do's the statement is incomplete.) More involved checking is implemented for if statements to account for nesting of block and logical if statements. If the statement is incomplete, the pressed key is reassigned as alt-enter (the new line key) and the enter case falls through to the alt-enter case. Implemented for function, subroutine, do, and if. The REPL example_input.txt test file is also modified to test some of these features.

Edited by Dominic Poerio

Merge request reports