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

"palparse" question

12 views
Skip to first unread message

John H Meyers

unread,
Jun 30, 1996, 3:00:00 AM6/30/96
to
Both Kermit RECV and "palparse" seem to produce the exact same results,
given the same ascii string (after any translation), except in the single
case of a string like "<<..>>", for which Kermit stores the program object
by itself, while "palparse" instead produces the secondary :: Q <<..>> ;
where Q represents the same invisible quoting command that the parser
uses to cause program objects within programs to be put on the stack
instead of executed ( #2349Ch = xSILENT' ).

I wonder whether there already exists a separately executable ROM function
which distinguishes this special case and extracts just the program object?

Note that strings defining more than one object are always converted to
a secondary, even if the first object is a program, so that there is
some logic involved in this function (secondary must contain exactly
two objects, first object must be quote, second object must be program),
which is why I'd rather find the ROM code than have to add my own code
after invoking "palparse" in the following user RPL:

@ "string" -> unevaluated object, except "<<..>>" -> :: Q <<..>> ;
\<< IF DUP TYPE 2 == THEN @ (string)
#238A4h SYSEVAL @ palparse
{ #5380Eh SYSEVAL } EVAL @ COERCEFLAG
NOT { DROP2 262 DOERR } IFT @ Invalid Syntax
ELSE 514 DOERR END @ Bad Argument Type
\>> @ 117 bytes, #AE10h checksum

Thanks for any clues!

-----------------------------------------------------------
With best wishes from: John H Meyers ( jhme...@mum.edu )

D Kirkland

unread,
Jul 3, 1996, 3:00:00 AM7/3/96
to

John H Meyers (jhme...@miu.edu) wrote:
: Both Kermit RECV and "palparse" seem to produce the exact same results,

Actually, I think it would be better to rewrite the above
program in sysRPL:

::
CK1NoBlame
CK&DISPATCH1
THREE
::
palparse
?SEMI
2DROP
SYNTAXERR
;
;

(This does exactly what your program does and is only
27.5 bytes!)

RECV uses a command that is slightly different from palparse.
It uses the same subroutines, but it sets a 'IOinprogress'
flag and then uses error traps and such to go back and get
more tokens when it runs out. And, as you have noted, it
removes program objects and such from inside the secondary
that is created.

The ROM routine used seems to be the same on all HP48, but
it is 'unsupported' so use at your own risk...
Also, you will need to make sure you know how to use the
routine correctly (most important is that it starts with
SWAPDROP).

The routine is PTR 25934 (# 25934h).

PTR 25934 expects objects on two stack levels upon entry.
The object on level two will be dropped (SWAPDROP).
The object on level one will be checked, if it is a
secondary with two objects, the first being xSILENT',
then it will return the second object and three TRUEs.
Otherwise it will return the object on level one and
three TRUEs. In other words, it always returns an object
and three TRUEs.

In RECV, the parser puts an empty list on the stack above
the string to be parsed for a marker. PTR 25934 starts
with a SWAPDROP to drop this empty list. The three TRUEs
are used internally by RECV.

The easiest way to use PTR 25934 is likely:

(with parsed object on stack level one...)

DUP
PTR 25934
3DROP

(leaves parsed object on stack level one...)

So rewriting your program in sysRPL and adding this:

::
CK1NoBlame
CK&DISPATCH1
THREE
::
palparse
NOTcase2drop
SYNTAXERR
DUP
PTR 25934
3DROP
;
;

(Only 32.5 bytes...)


dan (kirk...@ee.utah.edu)

0 new messages