Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #56805
| From | Alex <alex@rivadpm.com> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: Recognizer for quoted strings |
| Date | 2017-04-07 08:41 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <oc7fko$k7r$1@dont-email.me> (permalink) |
| References | <oc6gcl$hu1$1@dont-email.me> <oc6jr4$k0e$1@cherry.spenarnc.xs4all.nl> |
On 4/7/2017 00:43, Albert van der Horst wrote: > In article <oc6gcl$hu1$1@dont-email.me>, Alex <alex@rivadpm.com> wrote: >> http://amforth.sourceforge.net/TG/recipes/Recognizer.html >> >> A corrected recognizer for quoted strings using the latest RFC-D spec >> http://amforth.sourceforge.net/pr/Recognizer-rfc-D.pdf >> >> : pslit postpone sliteral ; >> >> ' noop >> :noname pslit ; >> :noname pslit postpone pslit ; >> dt-token: dt:string >> >> : rec:string ( addr len -- ) >> swap c@ [char] " = if >> negate >in +! \ move back the parse area >> [char] " parse >> dt:string \ get up to trailing " >> else drop dt:null then ; >> >> ' rec:string get-recognizers 1+ set-recognizers > > Note that for > "AAP NOOT MIES" > "AAP is passed to the recognizer conglomerate. > Then we have multiple cases and one is to decide to go > back and go parsing for the &" anyway. > > Compare this to the prefix solution: > > : " POSTPONE SKIP &" PARSE $, $@ POSTPONE DLITERAL ; PREFIX IMMEDIATE > > (The skip is there to skip over the string in compile mode.) > That is all, to add strings, in hindsight, as a loadable extension. > > What is separated off is " directly, as it should be. > No manipulation with execution tokens. " is almost a regular > word. No data structures to hold all those execution tokens. > Just PREFIX and one line in (FIND). The recognizer shown allows postponing strings, and recognizers can be built out of regular Forth. > > Of course the recognizers can do more. Stuff I don't want like > the trailing H for hex as in intel's 80004E5AH. If you don't like it, don't do it. > > If we must complicate Forth than with words that parse ahead, > not back and Forth. That's just a matter of taste, since "AAP NOOT MIES" ends up as a address & length pair whatever system is used, and no animals or small children are harmed in the process. > >> -- >> Alex -- Alex
Back to comp.lang.forth | Previous | Next — Previous in thread | Find similar | Unroll thread
Recognizer for quoted strings Alex <alex@rivadpm.com> - 2017-04-06 23:47 +0100
Re: Recognizer for quoted strings albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-04-07 01:43 +0200
Re: Recognizer for quoted strings Alex <alex@rivadpm.com> - 2017-04-07 08:41 +0100
csiph-web