diff --git a/rec-tick.fs b/rec-tick.fs new file mode 100644 index 000000000..33271efeb --- /dev/null +++ b/rec-tick.fs @@ -0,0 +1,31 @@ +\ (back-)tick recognizer +\ `foo puts the xt of foo on the stack like ' foo does + +\ Copyright (C) 2018 Free Software Foundation, Inc. + +\ This file is part of Gforth. + +\ Gforth is free software; you can redistribute it and/or +\ modify it under the terms of the GNU General Public License +\ as published by the Free Software Foundation, either version 3 +\ of the License, or (at your option) any later version. + +\ This program is distributed in the hope that it will be useful, +\ but WITHOUT ANY WARRANTY; without even the implied warranty of +\ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +\ GNU General Public License for more details. + +\ You should have received a copy of the GNU General Public License +\ along with this program. If not, see http://www.gnu.org/licenses/. + +' noop ' lit, ' lit, rectype: rectype-tick + +: rec-tick ( addr u -- xt rectype-tick | rectype-null ) + \G words prefixed with @code{'`'} return their xt. + \G Example: @code{`dup} gives the xt of dup + over c@ '`' <> if 2drop rectype-null exit then + 1 /string find-name + dup 0= if drop rectype-null exit then + rectype-tick ; + +' rec-tick forth-recognizer >back diff --git a/smartdots.fs b/smartdots.fs index b1229f5c5..b795fe7ac 100644 --- a/smartdots.fs +++ b/smartdots.fs @@ -32,7 +32,7 @@ : .string. ( addr u -- ) '"' emit type '"' emit space ; : .addr. ( addr -- ) - dup >name dup IF ." '" .name drop ELSE drop hex. THEN ; + dup >name dup IF ." `" .name drop ELSE drop hex. THEN ; : .var. ( addr -- ) dup body> >name dup IF .name drop ELSE drop hex. THEN ; diff --git a/startup.fs b/startup.fs index 042de8771..543c27dd4 100644 --- a/startup.fs +++ b/startup.fs @@ -53,6 +53,7 @@ require history.fs require quotes.fs require rec-string.fs require rec-to.fs +require rec-tick.fs require substitute.fs require code.fs require see.fs