most languages that can run in interactive mode have some kind of
welcome message and prompt that is printed before the user can give any
input.
For example, Python prints:
Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit
(Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>>
and another well-known language being implemented for Parrot, Lua:
Lua 5.1.1 Copyright (C) 1994-2006 Lua.org, PUC-Rio
>
Attached is a patch that extends HLLCompiler with 2 attributes:
commandline_message, and commandline_prompt
The first can be set to set the message to be shown when the interactive
mode is entered. The second one is the prompt to be printed before the
user can give input. (a possible improvement would be to have an array
of prompts; many languages have 2 prompts, when a "\" or whatever is
given. In Python, if one gives "\" at the end of the line, the next
prompt is "...". In lua it is ">>" instead of the normal prompt ">".)
As an example, I used this in Pynie.pir, which prints nicely:
C:\parrot\languages\pynie>..\..\parrot pynie.pbc
Python 2.5 for Parrot
Type "help", "copyright", "credits" or "license" for more information.
>>>
(although the "help" etc. commands are not implemented).
I don't know if this feature is desired, but it was not too much work,
and it makes languages look more like the real thing.
regards,
klaas-jan
Yes, this is helpful. But also one of the things we need is a way
so that we can have "additional input" -- i.e., when entering
constructs that span multiple lines, for the language to be able
to signal HLLCompiler to obtain additional lines of input.
> (a possible improvement would be to have an array
> of prompts; many languages have 2 prompts, when a "\" or whatever is
> given. In Python, if one gives "\" at the end of the line, the next
> prompt is "...". In lua it is ">>" instead of the normal prompt ">".)
I think we need to go ahead and have it possible to use an
array of prompts.
> As an example, I used this in Pynie.pir, which prints nicely:
>
> C:\parrot\languages\pynie>..\..\parrot pynie.pbc
> Python 2.5 for Parrot
> Type "help", "copyright", "credits" or "license" for more information.
> >>>
I'm generally in favor of not making false promises. So,
don't offer options that aren't available. :-)
Similarly, Pynie was modeled on Python 2.3, not 2.5... but if
someone has a copy of Python's 2.5 specification (or can point me
to it on the web), we can do 2.5.
Pm
$P0.'joinlinechar'('\')
sets the "\" character to be the signal to HLLCompiler to keep reading
from the next line.
($P0 holds the compiler object).
>
> I think we need to go ahead and have it possible to use an
> array of prompts.
>
ok. I've added it, but it only uses prompts[0] right now... (the main
prompt). It also needs an attribute that keeps track of what prompt
needs to be used (an index).
kjs
FYI, in tcl, the two prompts can be overridden via a user defined
procedure. See http://www.tcl.tk/man/tcl8.5/UserCmd/tclsh.htm#M11
Be nice if this was also possible with the default tool.
--
Will "Coke" Coleda
wi...@coleda.com
$P0.'set_prompt'(0, ">>>")
$P0.'set_prompt'(1, "...")
(in case of Python/Pynie)
It should overwrite the prompt in that slot.
kjs
commandline_banner could be a better name than commandline_message.
François.