43 lines
1.2 KiB
Forth
Executable File
43 lines
1.2 KiB
Forth
Executable File
#! /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
|