unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* REPL reader of multi-language
@ 2014-05-30  8:25 Nala Ginrut
  2014-05-30 12:48 ` Mike Gerwitz
  2014-05-30 19:08 ` Ludovic Courtès
  0 siblings, 2 replies; 5+ messages in thread
From: Nala Ginrut @ 2014-05-30  8:25 UTC (permalink / raw)
  To: guile-devel

hi folks!
When I'm hacking guile-lua on Guile, I realize that some languages may
need two different reader for REPL(interactive environment) and
compiler.

For an instance, the reader in Lua REPL has little different from its
compiler reader:
------------------------------cut-------------------------------------
In interactive mode, Lua usually interprets each line that you type as a
complete chunk. However, if it detects that the line cannot form a
complete chunk, it waits for more input, until it has a complete chunk.
When Lua is waiting for a line continuation, it shows a different
prompt...
------------------------------end--------------------------------------

But in Lua compiler/interpreter, a chunk(the minimum unit of compiling)
will be detected when the reader encounters EOF. Except for -l option
which let you input multiple chunks from command line.

It's not a problem for Ecmascript, because its statement has to be ended
with semicolon. So it's easier to detect the minimum compiling unit in
REPL. 
Lua accepts semicolon as an optional ending token. But it's strange to
force users to input semicolon or Ctrl+d to see the result in REPL. It's
better to mimic original Lua REPL.


So here's my problem, there's only one reader slot defined in each
language type ,say, in (system base language). I have to implement just
one reader to fit them all:
1. If I provide the interactive reader in Guile, the reader becomes
inefficient. Because each time users input `Enter', the source code
typed so far will be detected in lalr-parser, and exception would be
caught when the line doesn't complete a chunk, then the REPL returns
continue prompt, say '...'.

2. If I provide compiler reader, people have to type semicolon or ctrl+d
to see the result.


Here's my solution:
1. Provide two readers in language type, repl-reader and reader. And let
the frontend writers decide how to use;
2. Another way is to set a flag when we're in interactive mode. But I
didn't find the mechanism in our repl modules;
3. I saw there're various hooks in REPL, but there' no any docs for
them. Maybe there's chance to take advantage of them?

Any help?





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-06-03  6:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-30  8:25 REPL reader of multi-language Nala Ginrut
2014-05-30 12:48 ` Mike Gerwitz
2014-06-03  6:58   ` Nala Ginrut
2014-05-30 19:08 ` Ludovic Courtès
2014-06-03  6:36   ` Nala Ginrut

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).