2017-10-20 04:57:30 +02:00
|
|
|
# Syntax
|
|
|
|
|
2017-10-22 20:39:45 +02:00
|
|
|
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.
|
2017-10-20 04:57:30 +02:00
|
|
|
|
|
|
|
So:
|
|
|
|
|
|
|
|
[prefix][token]
|
|
|
|
|
2017-10-22 20:39:45 +02:00
|
|
|
Prefixes are single character modifiers. They are similar to colors in
|
|
|
|
ColorForth, but are handled via words in the `prefix:` namespace.
|
2017-10-20 04:57:30 +02:00
|
|
|
|
|
|
|
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:
|
|
|
|
|
2018-04-25 18:57:28 +02:00
|
|
|
~~~
|
2017-10-20 04:57:30 +02:00
|
|
|
(This_is_a_comment)
|
|
|
|
|
|
|
|
(Define_some_words)
|
|
|
|
:hello (-)
|
2018-05-07 18:39:49 +02:00
|
|
|
'Hello_World! s:put nl ;
|
2017-10-20 04:57:30 +02:00
|
|
|
|
|
|
|
: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
|
2018-05-07 18:39:49 +02:00
|
|
|
&s:put call
|
2017-10-20 04:57:30 +02:00
|
|
|
|
|
|
|
'Foo var
|
|
|
|
#100 !Foo
|
2018-05-07 18:39:49 +02:00
|
|
|
@Foo n:put
|
2018-04-25 18:57:28 +02:00
|
|
|
~~~
|