retroforth/doc/Syntax.md
crc e549b4ced6 no longer use ```` for code blocks; this fence sequence will be used for embedded tests in a later update
FossilOrigin-Name: dfed0de00b8d63672a882b79c4951cce0076007ef208c063b2f4e54fe9bd08f8
2018-04-25 16:57:28 +00:00

1.1 KiB

Syntax

RETRO code consists of a series of whitespace delimited tokens. Each of these can have an optional prefix telling RETRO how to treat the token. If the token lacks a valid prefix, it will be treated as a word name.

So:

[prefix][token]

Prefixes are single character modifiers. They are similar to colors in ColorForth, but are handled via words in the prefix: namespace.

The major prefixes are:

Prefix Used For
@ Fetch from variable
! Store into variable
& Pointer to named item
# Numbers
$ ASCII characters
' Strings
( Comments
: Define a word

Example:

(This_is_a_comment)

(Define_some_words)
:hello  (-)
  'Hello_World! puts nl ;

:n:square  (n-m)
  dup * ;

(Use_them)
hello
#33 n:square

(More_Things)
$a (this_is_the_ASCII_'a')

'Use_underscores_in_place_of_spaces_in_strings
&puts call

'Foo var
#100 !Foo
@Foo putn