Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #21720
| From | Bernd Paysan <bernd.paysan@gmx.de> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: Is there any way to change literal interpretation behavior to instead of push in the stack when typed, it be compiled in target image ? |
| Date | 2013-04-18 00:14 +0200 |
| Organization | 1&1 Internet AG |
| Message-ID | <kkn6rk$kp0$1@online.de> (permalink) |
| References | <48a6042e-6a7d-498e-8fd9-1131015f20e1@googlegroups.com> |
caio rodrigues wrote:
> Is there any way to change Forth( Gforth ) interpretation behavior to :
> for example if I type a number $FA87 , instead of push in the stack,
> execute $FA87 DOLIT , where DOLIT compile the number $FA87 in the target
> rom image ? I am using Gforth.
There's no easy way in the last stable distribution, but the current Git
repository Gforth has recognizers. What you need is to replace the num-
recognizer on the recognizer stack with your own number recognizer, which
would work like this:
: r:tnum ( n -- ) DOLIT , ;
comp: true abort" don't compile in target mode" ;
post: true abort" don't postpone in target mode" ;
: r:t2num ( d -- ) swap DOLIT , DOLIT , ;
comp: true abort" don't compile in target mode" ;
post: true abort" don't postpone in target mode" ;
\ snumber? should be implemented as recognizer stack
: tnum-recognizer ( addr u -- n/d table | r:fail )
snumber? dup
IF
0> IF ['] r:t2num ELSE ['] r:tnum THEN EXIT
THEN
drop ['] r:fail ;
And the replacement woudl be
forth-recognizer get-recognizers rot drop ' tnum-recognizer -rot
forth-recognizer set-recognizers
--
Bernd Paysan
"If you want it done right, you have to do it yourself"
http://bernd-paysan.de/
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar
Is there any way to change literal interpretation behavior to instead of push in the stack when typed, it be compiled in target image ? caio rodrigues <caiorss.rodrigues@gmail.com> - 2013-04-17 13:52 -0700 Re: Is there any way to change literal interpretation behavior to instead of push in the stack when typed, it be compiled in target image ? Bernd Paysan <bernd.paysan@gmx.de> - 2013-04-18 00:14 +0200 Re: Is there any way to change literal interpretation behavior to instead of push in the stack when typed, it be compiled in target image ? "Elizabeth D. Rather" <erather@forth.com> - 2013-04-18 22:01 -1000
csiph-web