Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[PATCH] welcome message and prompt for HLLCompiler

0 views
Skip to first unread message

Klaas-Jan Stol

unread,
Feb 25, 2007, 10:39:17 AM2/25/07
to Perl 6 Internals
hi,

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

commandlineprompt_and_message_for_HLLComp.patch

Patrick R. Michaud

unread,
Feb 25, 2007, 10:49:10 AM2/25/07
to Klaas-Jan Stol, Perl 6 Internals
On Sun, Feb 25, 2007 at 04:39:17PM +0100, Klaas-Jan Stol wrote:
> 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.

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

Klaas-Jan Stol

unread,
Feb 25, 2007, 11:24:29 AM2/25/07
to Patrick R. Michaud, Perl 6 Internals
Patrick R. Michaud wrote:
> On Sun, Feb 25, 2007 at 04:39:17PM +0100, Klaas-Jan Stol wrote:
>
>> 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.
>>
>
> 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 ">".)
>>
The escape character to continue on the next line should also be handled
by HLLCompiler?
something like

$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

Will Coleda

unread,
Feb 25, 2007, 11:37:22 AM2/25/07
to Klaas-Jan Stol, Patrick R. Michaud, Perl 6 Internals
Nifty.

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


Klaas-Jan Stol

unread,
Feb 25, 2007, 11:50:15 AM2/25/07
to Will Coleda, Patrick R. Michaud, Perl 6 Internals
Will Coleda wrote:
> Nifty.
>
> 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.
yup that should be possible as long as the language can access its own
compiler object. Just call

$P0.'set_prompt'(0, ">>>")
$P0.'set_prompt'(1, "...")

(in case of Python/Pynie)
It should overwrite the prompt in that slot.

kjs

Francois Perrad

unread,
Feb 27, 2007, 10:01:28 AM2/27/07
to Klaas-Jan Stol, Perl 6 Internals
At 16:39 25/02/2007 +0100, Klaas-Jan Stol wrote:
>hi,
>
>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

commandline_banner could be a better name than commandline_message.

François.

0 new messages