Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #56864
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: Recognizers & EVALUATE recursion |
| Date | 2017-04-08 14:17 +0000 |
| Organization | Institut fuer Computersprachen, Technische Universitaet Wien |
| Message-ID | <2017Apr8.161733@mips.complang.tuwien.ac.at> (permalink) |
| References | <oc85qd$t56$1@dont-email.me> |
Alex <alex@rivadpm.com> writes:
>Using EVALUATE or allowing an implicit use of EVALUATE in the execution
>path of a recognizer may cause problems. In my Forth (edited for clarity):
>
>: interpreter ( -- )
> begin parse-name dup
> while default-recognize execute
> repeat 2drop ;
>
>: evaluate ( addr len -- )
> ['] interpreter execute-parsing ;
>
>A recognizer using EVALUATE re-drives the interpreter, and hence the
>recognizer is potentially recursed into.
>
>Not every parse will cause issues, but there are certain pathological
>cases where the recogniser may infinitely recurse. In my case it was an
>EVALUATE for :NAME causing an EVALUATE for :NAME ... and so on.
Recursion is just like loops: You have to make at least a little bit
of progress before recursing, or you will get an endless recursion (at
least with recursion that usually shows up as a return stack overflow
rather than just a hanging program).
In general EVALUATE looks like a much too coarse tool for the
implementation of a recognizer: it can do many things out of your
control, based on stuff like STATE, BASE, the search order, and the
contents of the individual wordlists. A slightly less coarse approach
is to call the recognizer stack again (at least STATE should not
influence that), but of course the issue of requiring progress
remains.
- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2016: http://www.euroforth.org/ef16/
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Recognizers & EVALUATE recursion Alex <alex@rivadpm.com> - 2017-04-07 14:59 +0100
Re: Recognizers & EVALUATE recursion Matthias Trute <matthias.trute@gmail.com> - 2017-04-07 08:12 -0700
Re: Recognizers & EVALUATE recursion Alex <alex@rivadpm.com> - 2017-04-09 22:39 +0100
Re: Recognizers & EVALUATE recursion anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-04-08 14:17 +0000
Re: Recognizers & EVALUATE recursion Alex <alex@rivadpm.com> - 2017-04-09 22:37 +0100
csiph-web