Added into example.
This commit is contained in:
@ -50,7 +50,7 @@ create FOR ' >r @ ' for ! : for 1 nest-depth +! ['] for , here ; immed
|
|||||||
create NEXT ' donext @ ' next ! : next -1 nest-depth +! ['] next , , ; immediate
|
create NEXT ' donext @ ' next ! : next -1 nest-depth +! ['] next , , ; immediate
|
||||||
|
|
||||||
( Define a data type for Recognizers. )
|
( Define a data type for Recognizers. )
|
||||||
: RECTYPE: ( xt1 xt2 xt3 "name" -- ) CREATE , , , ;
|
: RECTYPE: ( xt-interpret xt-compile xt-postpone "name" -- ) CREATE , , , ;
|
||||||
: do-notfound ( a n -- ) -1 'notfound @ execute ;
|
: do-notfound ( a n -- ) -1 'notfound @ execute ;
|
||||||
' do-notfound ' do-notfound ' do-notfound RECTYPE: RECTYPE-NONE
|
' do-notfound ' do-notfound ' do-notfound RECTYPE: RECTYPE-NONE
|
||||||
' execute ' , ' postpone, RECTYPE: RECTYPE-WORD
|
' execute ' , ' postpone, RECTYPE: RECTYPE-WORD
|
||||||
|
|||||||
42
examples/into.fs
Executable file
42
examples/into.fs
Executable file
@ -0,0 +1,42 @@
|
|||||||
|
#! /usr/bin/env ueforth
|
||||||
|
|
||||||
|
\ Copyright 2024 Bradley D. Nelson
|
||||||
|
\
|
||||||
|
\ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
\ you may not use this file except in compliance with the License.
|
||||||
|
\ You may obtain a copy of the License at
|
||||||
|
\
|
||||||
|
\ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
\
|
||||||
|
\ Unless required by applicable law or agreed to in writing, software
|
||||||
|
\ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
\ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
\ See the License for the specific language governing permissions and
|
||||||
|
\ limitations under the License.
|
||||||
|
|
||||||
|
also recognizers also internals
|
||||||
|
|
||||||
|
: ->ex execute ;
|
||||||
|
: ->, >r aliteral r> , ;
|
||||||
|
: ->post >r aliteral r> postpone aliteral postpone, ;
|
||||||
|
' ->ex ' ->, ' ->post rectype: rectype-to
|
||||||
|
|
||||||
|
: prefix? { a n b m -- 0 | a' n' -1 }
|
||||||
|
n m 1+ < if 0 exit then
|
||||||
|
m 0 do a i + c@ b i + c@ <> if 0 unloop exit then loop
|
||||||
|
a m + n m - -1
|
||||||
|
;
|
||||||
|
|
||||||
|
: rec-to ( a n -- )
|
||||||
|
s" ->" prefix? 0= if rectype-none exit then
|
||||||
|
find dup 0= if drop rectype-none exit then
|
||||||
|
>body ['] ! rectype-to
|
||||||
|
; ' rec-to +recognizer
|
||||||
|
|
||||||
|
: rec-+to ( a n -- )
|
||||||
|
s" +->" prefix? 0= if rectype-none exit then
|
||||||
|
find dup 0= if drop rectype-none exit then
|
||||||
|
>body ['] +! rectype-to
|
||||||
|
; ' rec-+to +recognizer
|
||||||
|
|
||||||
|
previous previous
|
||||||
Reference in New Issue
Block a user