Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #54302
| From | Alex <alex@rivadpm.com> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: Recognizers |
| Date | 2017-01-23 08:30 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <o650dq$lpb$1@dont-email.me> (permalink) |
| References | <o61k4o$9he$1@dont-email.me> |
On 1/22/2017 01:42, Alex wrote:
> Some recognizer observations.
Refer to http://amforth.sourceforge.net/pr/Recognizer-rfc-C.html
3. Having R:FAIL not on the recognizer stack is inflexible. When
supporting more than one stack, the same R:FAIL appears as the last
implied entry in all of them, and an action like -13 THROW may not be
right for every situation. E.g. I may want to support forward
definitions on "not found" rather than throw an error.
The solutions would appear to be:
a. Modify the R:FAIL table when switching stacks. Messy and requires
setting 3 entries in the table at R:FAIL and the value of
FORTH-RECOGNIZER. Very difficult to manage, especially when recovery in
CATCH might require restoring the default recognition stack.
b. Require each stack to have its own R:FAIL equivalent action as the
last entry in the stack. There are some objections raised in the RfD at
"FLAGS, R:FAIL or EXCEPTIONS".
c. Maintain the current R:FAIL but avoid executing it by adding an
R:FAIL<this stack> to the bottom of those stacks that require it with
SET-RECOGNIZERS to catch unresolved requests.
Given that I believe the stack will only infrequently change dynamically
and that I'll be using mainly static FORTH-RECOGNIZERs, I'm going to use
approach C and have a "catch all" before the built-in R:FAIL.
My application for this is meta-compilation. While generating code
during meta-compilation I'm using a META-RECOGNIZER stack, and the
actions of the standard REC:NAME, REC:NUM etc are metacompilation
actions META:NAME and META:NUM, and I wish to use R:FAIL (now META:FAIL
prior to the default R:FAIL) to provide forward declarations without
having to declare them in advance.
Standard stack:
' REC:NAME ' REC:NUM 2 FORTH-RECOGNIZER SET-RECOGNIZERS
Meta stack:
4 RECOGNIZER META-RECOGNIZER
' META:FAIL ' META:NAME ' META:NUM 3 META-RECOGNIZER SET-RECOGNIZERS
4. Varying stack item counts from REC:<name> words.
This one has caused me a lot of grief while debugging.
: rec:num ( addr u -- d r:num | r:fail )
5. Names.
I haven't found a use for R>COMP R>INT or R>POST. Also, the names are a
little suspect; why not match NAME>X and have R>INTERPRET R>COMPILE and
R>POSTPONE (if they are required).
R:<name> (a table) and REC:<name> (a word) are too similar, and an
attempt has been made to semi-standardize them.
RECOGNIZER would be clearer as RECOGNIZER-STACK
DO-RECOGNIZER I have implemented as the verb RECOGNIZE; it leads to
pretty understandable code like this (?STACK is an underflow test on the
data stack).
: interpreter ( -- ) \ outer interpreter
begin ?stack parse-name dup
while recognize execute
repeat 2drop ;
--
Alex
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Recognizers Alex <alex@rivadpm.com> - 2017-01-22 01:42 -0500
Re: Recognizers Matthias Trute <matthias.trute@gmail.com> - 2017-01-22 03:06 -0800
Re: Recognizers anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-01-22 14:42 +0000
Re: Recognizers Alex <alex@rivadpm.com> - 2017-01-22 17:26 -0500
Re: Recognizers Bernd Paysan <bernd@net2o.de> - 2017-01-24 00:57 +0000
Re: Recognizers anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-01-24 16:23 +0000
Re: Recognizers Bernd Paysan <bernd@net2o.de> - 2017-01-24 21:47 +0000
Re: Recognizers Alex <alex@rivadpm.com> - 2017-01-23 08:30 -0500
Re: Recognizers Alex <alex@rivadpm.com> - 2017-01-23 08:57 -0500
Re: Recognizers Matthias Trute <matthias.trute@gmail.com> - 2017-01-23 10:58 -0800
Re: Recognizers Alex <alex@rivadpm.com> - 2017-01-23 14:45 -0500
Re: Recognizers JennyB <jennybrien@googlemail.com> - 2017-01-27 15:05 -0800
Re: Recognizers Alex <alex@rivadpm.com> - 2017-01-29 22:54 +0000
Re: Recognizers JennyB <jennybrien@googlemail.com> - 2017-01-30 09:11 -0800
Re: Recognizers anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-01-30 16:34 +0000
Re: Recognizers Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2017-01-31 21:03 +0000
Re: Recognizers albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-02-01 12:37 +0100
csiph-web