Re:Reple: “Replay-Based” REPLs for Compiled Languages
by xiii1408 on Saturday December 22, 2018 @07:19PM
(#18743419)
It's actually pretty easy to detect multi-line inputs as long as they have clear enclosers (like '{}' for a block in C/C++). This is what reple does.
This doesn't require a parser--you just have to know what the enclosers are (one of the things that goes in a reple config file) and then count them to see if they're matched or not.
For languages without Python-like syntax or with enclosers that can be ambiguous (some dialects of Fortran), this would be pretty difficult.
I'd guess this approach also struggles with multiple-line input like if/else, loops, functions.
I'm reminded of https://github.com/jcartledge/sublime-worksheet which is language-agnostic on the other end of things. The two ideas might work well together in limited cases.