Added into example.

This commit is contained in:
Brad Nelson
2024-11-08 19:12:02 -08:00
parent 51c224affd
commit af641b0578
2 changed files with 43 additions and 1 deletions

42
examples/into.fs Executable file
View 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