title: What is a good approach to constructing a modular parser both for REPL interpreters and compilers?
body: <p>What is a good approach to build a versatile parser both for REPL interpreters and compilers? What I mean by the interpreters is kind of a read-eval-print loop. 
  To support both of them, the parser should support a whole program parsing and a line-by-line parsing. The LALR(1) algorithm introduced by the Dragon book is good for a whole program parsing, but it should be engineered a little bit for being used to support a line-by-line parsing simultaneously. Since the two styles of the parsing share the same grammar for the programming language, I believe that there would be a modular method for building a single parser for the two purposes, but I can't find it. Can you help me on this matter? </p>