prefix: namespace is now sigil:, rename words, update examples, update docs
FossilOrigin-Name: 25cf19660ab7728d7bfee2722ea826a8a438faf92b2504b28d922d2958906aed
This commit is contained in:
parent
b43e63ee69
commit
6a4aaf8eac
55 changed files with 1860 additions and 1686 deletions
|
@ -2,6 +2,10 @@
|
|||
|
||||
## Core Language
|
||||
|
||||
## Renamed
|
||||
|
||||
- prefix: namespace to sigil:
|
||||
|
||||
## I/O
|
||||
|
||||
- simplify definition of `c:get`
|
||||
|
|
|
@ -1078,45 +1078,6 @@ Copy a string to the pasteboard.
|
|||
pop D: -n A: n- F: -
|
||||
Move a value from the return stack to the data stack.
|
||||
|
||||
prefix:! D: ns- A: - F: -
|
||||
Store a value into a variable.
|
||||
|
||||
prefix:# D: s-n A: - F: -
|
||||
Process token as a number.
|
||||
|
||||
prefix:$ D: s-c A: - F: -
|
||||
Process token as an ASCII character.
|
||||
|
||||
prefix:& D: s-a A: - F: -
|
||||
Return a pointer to a named item.
|
||||
|
||||
prefix:' D: s-s A: - F: -
|
||||
Process token as a string.
|
||||
|
||||
prefix:( D: s- A: - F: -
|
||||
Process token as a comment.
|
||||
|
||||
prefix:. D: s- A: - F: -F
|
||||
Interpret time: convert string to a floating point value. Compile time: convert string to a floating point value and compile code to push this value to the float stack.
|
||||
|
||||
prefix:: D: s- A: - F: -
|
||||
Process token as a new definition.
|
||||
|
||||
prefix:@ D: s-n A: - F: -
|
||||
Fetch from a stored variable.
|
||||
|
||||
prefix:\ D: s- A: - F: -
|
||||
Process token as an instruction bundle.
|
||||
|
||||
prefix:^ D: s- A: - F: -
|
||||
Process token as a function reference.
|
||||
|
||||
prefix:` D: s- A: - F: -
|
||||
Process token as a bytecode.
|
||||
|
||||
prefix:| D: s- A: - F: -
|
||||
POSTPONE equivalent.
|
||||
|
||||
primitive D: - A: - F: -
|
||||
Change the class of the most recently defined word to `class:primitive`.
|
||||
|
||||
|
@ -1324,6 +1285,45 @@ Patch the hook point in a2 to point to a1.
|
|||
shift D: mn-o A: - F: -
|
||||
Peform a bitwise shift of m by n bits. If n is positive, shift right. If negative, the shift will be to the left.
|
||||
|
||||
sigil:! D: ns- A: - F: -
|
||||
Store a value into a variable.
|
||||
|
||||
sigil:# D: s-n A: - F: -
|
||||
Process token as a number.
|
||||
|
||||
sigil:$ D: s-c A: - F: -
|
||||
Process token as an ASCII character.
|
||||
|
||||
sigil:& D: s-a A: - F: -
|
||||
Return a pointer to a named item.
|
||||
|
||||
sigil:' D: s-s A: - F: -
|
||||
Process token as a string.
|
||||
|
||||
sigil:( D: s- A: - F: -
|
||||
Process token as a comment.
|
||||
|
||||
sigil:. D: s- A: - F: -F
|
||||
Interpret time: convert string to a floating point value. Compile time: convert string to a floating point value and compile code to push this value to the float stack.
|
||||
|
||||
sigil:: D: s- A: - F: -
|
||||
Process token as a new definition.
|
||||
|
||||
sigil:@ D: s-n A: - F: -
|
||||
Fetch from a stored variable.
|
||||
|
||||
sigil:\ D: s- A: - F: -
|
||||
Process token as an instruction bundle.
|
||||
|
||||
sigil:^ D: s- A: - F: -
|
||||
Process token as a function reference.
|
||||
|
||||
sigil:` D: s- A: - F: -
|
||||
Process token as a bytecode.
|
||||
|
||||
sigil:| D: s- A: - F: -
|
||||
POSTPONE equivalent.
|
||||
|
||||
sip D: nq-n A: - F: -
|
||||
Run quote. After execution completes, put a copy of n back on top of the stack.
|
||||
|
||||
|
|
|
@ -358,19 +358,6 @@ pb:get D: a- A: - F: -
|
|||
pb:length D: -n A: - F: -
|
||||
pb:set D: s- A: - F: -
|
||||
pop D: -n A: n- F: -
|
||||
prefix:! D: ns- A: - F: -
|
||||
prefix:# D: s-n A: - F: -
|
||||
prefix:$ D: s-c A: - F: -
|
||||
prefix:& D: s-a A: - F: -
|
||||
prefix:' D: s-s A: - F: -
|
||||
prefix:( D: s- A: - F: -
|
||||
prefix:. D: s- A: - F: -F
|
||||
prefix:: D: s- A: - F: -
|
||||
prefix:@ D: s-n A: - F: -
|
||||
prefix:\ D: s- A: - F: -
|
||||
prefix:^ D: s- A: - F: -
|
||||
prefix:` D: s- A: - F: -
|
||||
prefix:| D: s- A: - F: -
|
||||
primitive D: - A: - F: -
|
||||
push D: n- A: -n F: -
|
||||
r D: s- A: - F: -
|
||||
|
@ -440,6 +427,19 @@ script:ignore-to-eol D: - A: - F: -
|
|||
script:name D: -s A: - F: -
|
||||
set-hook D: aa- A: - F: -
|
||||
shift D: mn-o A: - F: -
|
||||
sigil:! D: ns- A: - F: -
|
||||
sigil:# D: s-n A: - F: -
|
||||
sigil:$ D: s-c A: - F: -
|
||||
sigil:& D: s-a A: - F: -
|
||||
sigil:' D: s-s A: - F: -
|
||||
sigil:( D: s- A: - F: -
|
||||
sigil:. D: s- A: - F: -F
|
||||
sigil:: D: s- A: - F: -
|
||||
sigil:@ D: s-n A: - F: -
|
||||
sigil:\ D: s- A: - F: -
|
||||
sigil:^ D: s- A: - F: -
|
||||
sigil:` D: s- A: - F: -
|
||||
sigil:| D: s- A: - F: -
|
||||
sip D: nq-n A: - F: -
|
||||
socket:accept D: n-nn A: - F: -
|
||||
socket:bind D: sn-nn A: - F: -
|
||||
|
|
|
@ -18,14 +18,14 @@
|
|||
<b>Float:</b> -</p>
|
||||
</div>
|
||||
<p>Provide a visual indication of a code group.</p>
|
||||
<table><tr><td><b>Class:</b> </td><td>class:macro</td></tr><tr><td><b>Namespace:</b> </td><td>prefix</td></tr><tr><td><b>Interface Layer:</b> </td><td>all</td></tr></table><hr/>
|
||||
<table><tr><td><b>Class:</b> </td><td>class:macro</td></tr><tr><td><b>Namespace:</b> </td><td>sigil</td></tr><tr><td><b>Interface Layer:</b> </td><td>all</td></tr></table><hr/>
|
||||
<h2>)</h2>
|
||||
<div style='margin-left: 1em;'><p><b>Data:</b> -<br>
|
||||
<b>Addr:</b> -<br>
|
||||
<b>Float:</b> -</p>
|
||||
</div>
|
||||
<p>Provide a visual indication of a code group.</p>
|
||||
<table><tr><td><b>Class:</b> </td><td>class:macro</td></tr><tr><td><b>Namespace:</b> </td><td>prefix</td></tr><tr><td><b>Interface Layer:</b> </td><td>all</td></tr></table><hr/>
|
||||
<table><tr><td><b>Class:</b> </td><td>class:macro</td></tr><tr><td><b>Namespace:</b> </td><td>sigil</td></tr><tr><td><b>Interface Layer:</b> </td><td>all</td></tr></table><hr/>
|
||||
<h2>*</h2>
|
||||
<div style='margin-left: 1em;'><p><b>Data:</b> nn-n<br>
|
||||
<b>Addr:</b> -<br>
|
||||
|
@ -2725,166 +2725,6 @@
|
|||
</div>
|
||||
<p>Move a value from the return stack to the data stack.</p>
|
||||
<table><tr><td><b>Class:</b> </td><td>class:macro</td></tr><tr><td><b>Namespace:</b> </td><td>global</td></tr><tr><td><b>Interface Layer:</b> </td><td>all</td></tr></table><hr/>
|
||||
<h2>prefix:!</h2>
|
||||
<div style='margin-left: 1em;'><p><b>Data:</b> ns-<br>
|
||||
<b>Addr:</b> -<br>
|
||||
<b>Float:</b> -</p>
|
||||
</div>
|
||||
<p>Store a value into a variable.</p>
|
||||
<p>Interpret Time:
|
||||
Store a value into the named variable.</p>
|
||||
|
||||
<p>Compile Time:
|
||||
Compile the code to store a value into a named variable.</p>
|
||||
|
||||
<table><tr><td><b>Class:</b> </td><td>class:macro</td></tr><tr><td><b>Namespace:</b> </td><td>prefix</td></tr><tr><td><b>Interface Layer:</b> </td><td>all</td></tr></table><hr/>
|
||||
<h2>prefix:#</h2>
|
||||
<div style='margin-left: 1em;'><p><b>Data:</b> s-n<br>
|
||||
<b>Addr:</b> -<br>
|
||||
<b>Float:</b> -</p>
|
||||
</div>
|
||||
<p>Process token as a number.</p>
|
||||
<p>Interpret Time:
|
||||
Convert the string into a number and leave on the stack.</p>
|
||||
|
||||
<p>Compile Time:
|
||||
Convert the string into a number and compile into the current definition as a literal.</p>
|
||||
|
||||
<table><tr><td><b>Class:</b> </td><td>class:macro</td></tr><tr><td><b>Namespace:</b> </td><td>prefix</td></tr><tr><td><b>Interface Layer:</b> </td><td>all</td></tr></table><hr/>
|
||||
<h2>prefix:$</h2>
|
||||
<div style='margin-left: 1em;'><p><b>Data:</b> s-c<br>
|
||||
<b>Addr:</b> -<br>
|
||||
<b>Float:</b> -</p>
|
||||
</div>
|
||||
<p>Process token as an ASCII character.</p>
|
||||
<p>Interpret Time:
|
||||
Fetch first character from string. Leave on stack.</p>
|
||||
|
||||
<p>Compile Time:
|
||||
Fetch first character from the string. Compile into the current definition as literal.</p>
|
||||
|
||||
<table><tr><td><b>Class:</b> </td><td>class:macro</td></tr><tr><td><b>Namespace:</b> </td><td>prefix</td></tr><tr><td><b>Interface Layer:</b> </td><td>all</td></tr></table><hr/>
|
||||
<h2>prefix:&</h2>
|
||||
<div style='margin-left: 1em;'><p><b>Data:</b> s-a<br>
|
||||
<b>Addr:</b> -<br>
|
||||
<b>Float:</b> -</p>
|
||||
</div>
|
||||
<p>Return a pointer to a named item.</p>
|
||||
<p>Interpret Time:
|
||||
Lookup name in dictionary, return contents of the xt field on the stack.</p>
|
||||
|
||||
<p>Compile Time:
|
||||
Lookup name in dictionary, compile code to push the contents of the xt field into the current definition.</p>
|
||||
|
||||
<table><tr><td><b>Class:</b> </td><td>class:macro</td></tr><tr><td><b>Namespace:</b> </td><td>prefix</td></tr><tr><td><b>Interface Layer:</b> </td><td>all</td></tr></table><hr/>
|
||||
<h2>prefix:'</h2>
|
||||
<div style='margin-left: 1em;'><p><b>Data:</b> s-s<br>
|
||||
<b>Addr:</b> -<br>
|
||||
<b>Float:</b> -</p>
|
||||
</div>
|
||||
<p>Process token as a string.</p>
|
||||
<p>Interpret Time:
|
||||
Move string into temporary buffer. If `RewriteUnderscores` is `TRUE`, replace all instances of _ with space.</p>
|
||||
|
||||
<p>Compile Time:
|
||||
Move string into temporary buffer. If `RewriteUnderscores` is `TRUE`, replace all instances of _ with space. Then compile the string into the current definition.</p>
|
||||
|
||||
<table><tr><td><b>Class:</b> </td><td>class:macro</td></tr><tr><td><b>Namespace:</b> </td><td>prefix</td></tr><tr><td><b>Interface Layer:</b> </td><td>all</td></tr></table><hr/>
|
||||
<h2>prefix:(</h2>
|
||||
<div style='margin-left: 1em;'><p><b>Data:</b> s-<br>
|
||||
<b>Addr:</b> -<br>
|
||||
<b>Float:</b> -</p>
|
||||
</div>
|
||||
<p>Process token as a comment.</p>
|
||||
<p>Interpret Time:
|
||||
Discard the string.</p>
|
||||
|
||||
<p>Compile Time:
|
||||
Discard the string.</p>
|
||||
|
||||
<table><tr><td><b>Class:</b> </td><td>class:macro</td></tr><tr><td><b>Namespace:</b> </td><td>prefix</td></tr><tr><td><b>Interface Layer:</b> </td><td>all</td></tr></table><hr/>
|
||||
<h2>prefix:.</h2>
|
||||
<div style='margin-left: 1em;'><p><b>Data:</b> s-<br>
|
||||
<b>Addr:</b> -<br>
|
||||
<b>Float:</b> -F</p>
|
||||
</div>
|
||||
<p>Interpret time: convert string to a floating point value. Compile time: convert string to a floating point value and compile code to push this value to the float stack.</p>
|
||||
<table><tr><td><b>Class:</b> </td><td>class:macro</td></tr><tr><td><b>Namespace:</b> </td><td>prefix</td></tr><tr><td><b>Interface Layer:</b> </td><td>rre</td></tr></table><hr/>
|
||||
<h2>prefix::</h2>
|
||||
<div style='margin-left: 1em;'><p><b>Data:</b> s-<br>
|
||||
<b>Addr:</b> -<br>
|
||||
<b>Float:</b> -</p>
|
||||
</div>
|
||||
<p>Process token as a new definition.</p>
|
||||
<p>Interpret Time:
|
||||
Create a header pointing to `here` with the provided string as the name. Sets class to `class:word`.</p>
|
||||
|
||||
<table><tr><td><b>Class:</b> </td><td>class:macro</td></tr><tr><td><b>Namespace:</b> </td><td>prefix</td></tr><tr><td><b>Interface Layer:</b> </td><td>all</td></tr></table><hr/>
|
||||
<h2>prefix:@</h2>
|
||||
<div style='margin-left: 1em;'><p><b>Data:</b> s-n<br>
|
||||
<b>Addr:</b> -<br>
|
||||
<b>Float:</b> -</p>
|
||||
</div>
|
||||
<p>Fetch from a stored variable.</p>
|
||||
<p>Interpret Time:
|
||||
Fetch a value from a named variable.</p>
|
||||
|
||||
<p>Compile Time:
|
||||
Compile the code to fetch a value from a named variable into the current definition.</p>
|
||||
|
||||
<table><tr><td><b>Class:</b> </td><td>class:macro</td></tr><tr><td><b>Namespace:</b> </td><td>prefix</td></tr><tr><td><b>Interface Layer:</b> </td><td>all</td></tr></table><hr/>
|
||||
<h2>prefix:\</h2>
|
||||
<div style='margin-left: 1em;'><p><b>Data:</b> s-<br>
|
||||
<b>Addr:</b> -<br>
|
||||
<b>Float:</b> -</p>
|
||||
</div>
|
||||
<p>Process token as an instruction bundle.</p>
|
||||
<p>Interpret Time:
|
||||
Discard the string.</p>
|
||||
|
||||
<p>Compile Time:
|
||||
Assemble the opcodes in the string and use `,` to inline it into the current definition.</p>
|
||||
|
||||
<table><tr><td><b>Class:</b> </td><td>class:macro</td></tr><tr><td><b>Namespace:</b> </td><td>prefix</td></tr><tr><td><b>Interface Layer:</b> </td><td>all</td></tr></table><hr/>
|
||||
<h2>prefix:^</h2>
|
||||
<div style='margin-left: 1em;'><p><b>Data:</b> s-<br>
|
||||
<b>Addr:</b> -<br>
|
||||
<b>Float:</b> -</p>
|
||||
</div>
|
||||
<p>Process token as a function reference.</p>
|
||||
<p>Interpret Time:
|
||||
Discard the string.</p>
|
||||
|
||||
<p>Compile Time:
|
||||
Comma the XT of the word into the current definition.</p>
|
||||
|
||||
<table><tr><td><b>Class:</b> </td><td>class:macro</td></tr><tr><td><b>Namespace:</b> </td><td>prefix</td></tr><tr><td><b>Interface Layer:</b> </td><td>all</td></tr></table><hr/>
|
||||
<h2>prefix:`</h2>
|
||||
<div style='margin-left: 1em;'><p><b>Data:</b> s-<br>
|
||||
<b>Addr:</b> -<br>
|
||||
<b>Float:</b> -</p>
|
||||
</div>
|
||||
<p>Process token as a bytecode.</p>
|
||||
<p>Interpret Time:
|
||||
Discard the string.</p>
|
||||
|
||||
<p>Compile Time:
|
||||
Convert the string to a number and use `,` to inline it into the current definition.</p>
|
||||
|
||||
<table><tr><td><b>Class:</b> </td><td>class:macro</td></tr><tr><td><b>Namespace:</b> </td><td>prefix</td></tr><tr><td><b>Interface Layer:</b> </td><td>all</td></tr></table><hr/>
|
||||
<h2>prefix:|</h2>
|
||||
<div style='margin-left: 1em;'><p><b>Data:</b> s-<br>
|
||||
<b>Addr:</b> -<br>
|
||||
<b>Float:</b> -</p>
|
||||
</div>
|
||||
<p>POSTPONE equivalent.</p>
|
||||
<p>Interpret Time:
|
||||
Discard the string.</p>
|
||||
|
||||
<p>Compile Time:
|
||||
Convert the string to a number and use `,` to inline it into the current definition.</p>
|
||||
|
||||
<table><tr><td><b>Class:</b> </td><td>class:macro</td></tr><tr><td><b>Namespace:</b> </td><td>prefix</td></tr><tr><td><b>Interface Layer:</b> </td><td>all</td></tr></table><hr/>
|
||||
<h2>primitive</h2>
|
||||
<div style='margin-left: 1em;'><p><b>Data:</b> -<br>
|
||||
<b>Addr:</b> -<br>
|
||||
|
@ -3395,6 +3235,166 @@
|
|||
</div>
|
||||
<p>Peform a bitwise shift of m by n bits. If n is positive, shift right. If negative, the shift will be to the left.</p>
|
||||
<table><tr><td><b>Class:</b> </td><td>class:primitive</td></tr><tr><td><b>Namespace:</b> </td><td>global</td></tr><tr><td><b>Interface Layer:</b> </td><td>all</td></tr></table><hr/>
|
||||
<h2>sigil:!</h2>
|
||||
<div style='margin-left: 1em;'><p><b>Data:</b> ns-<br>
|
||||
<b>Addr:</b> -<br>
|
||||
<b>Float:</b> -</p>
|
||||
</div>
|
||||
<p>Store a value into a variable.</p>
|
||||
<p>Interpret Time:
|
||||
Store a value into the named variable.</p>
|
||||
|
||||
<p>Compile Time:
|
||||
Compile the code to store a value into a named variable.</p>
|
||||
|
||||
<table><tr><td><b>Class:</b> </td><td>class:macro</td></tr><tr><td><b>Namespace:</b> </td><td>sigil</td></tr><tr><td><b>Interface Layer:</b> </td><td>all</td></tr></table><hr/>
|
||||
<h2>sigil:#</h2>
|
||||
<div style='margin-left: 1em;'><p><b>Data:</b> s-n<br>
|
||||
<b>Addr:</b> -<br>
|
||||
<b>Float:</b> -</p>
|
||||
</div>
|
||||
<p>Process token as a number.</p>
|
||||
<p>Interpret Time:
|
||||
Convert the string into a number and leave on the stack.</p>
|
||||
|
||||
<p>Compile Time:
|
||||
Convert the string into a number and compile into the current definition as a literal.</p>
|
||||
|
||||
<table><tr><td><b>Class:</b> </td><td>class:macro</td></tr><tr><td><b>Namespace:</b> </td><td>sigil</td></tr><tr><td><b>Interface Layer:</b> </td><td>all</td></tr></table><hr/>
|
||||
<h2>sigil:$</h2>
|
||||
<div style='margin-left: 1em;'><p><b>Data:</b> s-c<br>
|
||||
<b>Addr:</b> -<br>
|
||||
<b>Float:</b> -</p>
|
||||
</div>
|
||||
<p>Process token as an ASCII character.</p>
|
||||
<p>Interpret Time:
|
||||
Fetch first character from string. Leave on stack.</p>
|
||||
|
||||
<p>Compile Time:
|
||||
Fetch first character from the string. Compile into the current definition as literal.</p>
|
||||
|
||||
<table><tr><td><b>Class:</b> </td><td>class:macro</td></tr><tr><td><b>Namespace:</b> </td><td>sigil</td></tr><tr><td><b>Interface Layer:</b> </td><td>all</td></tr></table><hr/>
|
||||
<h2>sigil:&</h2>
|
||||
<div style='margin-left: 1em;'><p><b>Data:</b> s-a<br>
|
||||
<b>Addr:</b> -<br>
|
||||
<b>Float:</b> -</p>
|
||||
</div>
|
||||
<p>Return a pointer to a named item.</p>
|
||||
<p>Interpret Time:
|
||||
Lookup name in dictionary, return contents of the xt field on the stack.</p>
|
||||
|
||||
<p>Compile Time:
|
||||
Lookup name in dictionary, compile code to push the contents of the xt field into the current definition.</p>
|
||||
|
||||
<table><tr><td><b>Class:</b> </td><td>class:macro</td></tr><tr><td><b>Namespace:</b> </td><td>sigil</td></tr><tr><td><b>Interface Layer:</b> </td><td>all</td></tr></table><hr/>
|
||||
<h2>sigil:'</h2>
|
||||
<div style='margin-left: 1em;'><p><b>Data:</b> s-s<br>
|
||||
<b>Addr:</b> -<br>
|
||||
<b>Float:</b> -</p>
|
||||
</div>
|
||||
<p>Process token as a string.</p>
|
||||
<p>Interpret Time:
|
||||
Move string into temporary buffer. If `RewriteUnderscores` is `TRUE`, replace all instances of _ with space.</p>
|
||||
|
||||
<p>Compile Time:
|
||||
Move string into temporary buffer. If `RewriteUnderscores` is `TRUE`, replace all instances of _ with space. Then compile the string into the current definition.</p>
|
||||
|
||||
<table><tr><td><b>Class:</b> </td><td>class:macro</td></tr><tr><td><b>Namespace:</b> </td><td>sigil</td></tr><tr><td><b>Interface Layer:</b> </td><td>all</td></tr></table><hr/>
|
||||
<h2>sigil:(</h2>
|
||||
<div style='margin-left: 1em;'><p><b>Data:</b> s-<br>
|
||||
<b>Addr:</b> -<br>
|
||||
<b>Float:</b> -</p>
|
||||
</div>
|
||||
<p>Process token as a comment.</p>
|
||||
<p>Interpret Time:
|
||||
Discard the string.</p>
|
||||
|
||||
<p>Compile Time:
|
||||
Discard the string.</p>
|
||||
|
||||
<table><tr><td><b>Class:</b> </td><td>class:macro</td></tr><tr><td><b>Namespace:</b> </td><td>sigil</td></tr><tr><td><b>Interface Layer:</b> </td><td>all</td></tr></table><hr/>
|
||||
<h2>sigil:.</h2>
|
||||
<div style='margin-left: 1em;'><p><b>Data:</b> s-<br>
|
||||
<b>Addr:</b> -<br>
|
||||
<b>Float:</b> -F</p>
|
||||
</div>
|
||||
<p>Interpret time: convert string to a floating point value. Compile time: convert string to a floating point value and compile code to push this value to the float stack.</p>
|
||||
<table><tr><td><b>Class:</b> </td><td>class:macro</td></tr><tr><td><b>Namespace:</b> </td><td>sigil</td></tr><tr><td><b>Interface Layer:</b> </td><td>rre</td></tr></table><hr/>
|
||||
<h2>sigil::</h2>
|
||||
<div style='margin-left: 1em;'><p><b>Data:</b> s-<br>
|
||||
<b>Addr:</b> -<br>
|
||||
<b>Float:</b> -</p>
|
||||
</div>
|
||||
<p>Process token as a new definition.</p>
|
||||
<p>Interpret Time:
|
||||
Create a header pointing to `here` with the provided string as the name. Sets class to `class:word`.</p>
|
||||
|
||||
<table><tr><td><b>Class:</b> </td><td>class:macro</td></tr><tr><td><b>Namespace:</b> </td><td>sigil</td></tr><tr><td><b>Interface Layer:</b> </td><td>all</td></tr></table><hr/>
|
||||
<h2>sigil:@</h2>
|
||||
<div style='margin-left: 1em;'><p><b>Data:</b> s-n<br>
|
||||
<b>Addr:</b> -<br>
|
||||
<b>Float:</b> -</p>
|
||||
</div>
|
||||
<p>Fetch from a stored variable.</p>
|
||||
<p>Interpret Time:
|
||||
Fetch a value from a named variable.</p>
|
||||
|
||||
<p>Compile Time:
|
||||
Compile the code to fetch a value from a named variable into the current definition.</p>
|
||||
|
||||
<table><tr><td><b>Class:</b> </td><td>class:macro</td></tr><tr><td><b>Namespace:</b> </td><td>sigil</td></tr><tr><td><b>Interface Layer:</b> </td><td>all</td></tr></table><hr/>
|
||||
<h2>sigil:\</h2>
|
||||
<div style='margin-left: 1em;'><p><b>Data:</b> s-<br>
|
||||
<b>Addr:</b> -<br>
|
||||
<b>Float:</b> -</p>
|
||||
</div>
|
||||
<p>Process token as an instruction bundle.</p>
|
||||
<p>Interpret Time:
|
||||
Discard the string.</p>
|
||||
|
||||
<p>Compile Time:
|
||||
Assemble the opcodes in the string and use `,` to inline it into the current definition.</p>
|
||||
|
||||
<table><tr><td><b>Class:</b> </td><td>class:macro</td></tr><tr><td><b>Namespace:</b> </td><td>sigil</td></tr><tr><td><b>Interface Layer:</b> </td><td>all</td></tr></table><hr/>
|
||||
<h2>sigil:^</h2>
|
||||
<div style='margin-left: 1em;'><p><b>Data:</b> s-<br>
|
||||
<b>Addr:</b> -<br>
|
||||
<b>Float:</b> -</p>
|
||||
</div>
|
||||
<p>Process token as a function reference.</p>
|
||||
<p>Interpret Time:
|
||||
Discard the string.</p>
|
||||
|
||||
<p>Compile Time:
|
||||
Comma the XT of the word into the current definition.</p>
|
||||
|
||||
<table><tr><td><b>Class:</b> </td><td>class:macro</td></tr><tr><td><b>Namespace:</b> </td><td>sigil</td></tr><tr><td><b>Interface Layer:</b> </td><td>all</td></tr></table><hr/>
|
||||
<h2>sigil:`</h2>
|
||||
<div style='margin-left: 1em;'><p><b>Data:</b> s-<br>
|
||||
<b>Addr:</b> -<br>
|
||||
<b>Float:</b> -</p>
|
||||
</div>
|
||||
<p>Process token as a bytecode.</p>
|
||||
<p>Interpret Time:
|
||||
Discard the string.</p>
|
||||
|
||||
<p>Compile Time:
|
||||
Convert the string to a number and use `,` to inline it into the current definition.</p>
|
||||
|
||||
<table><tr><td><b>Class:</b> </td><td>class:macro</td></tr><tr><td><b>Namespace:</b> </td><td>sigil</td></tr><tr><td><b>Interface Layer:</b> </td><td>all</td></tr></table><hr/>
|
||||
<h2>sigil:|</h2>
|
||||
<div style='margin-left: 1em;'><p><b>Data:</b> s-<br>
|
||||
<b>Addr:</b> -<br>
|
||||
<b>Float:</b> -</p>
|
||||
</div>
|
||||
<p>POSTPONE equivalent.</p>
|
||||
<p>Interpret Time:
|
||||
Discard the string.</p>
|
||||
|
||||
<p>Compile Time:
|
||||
Convert the string to a number and use `,` to inline it into the current definition.</p>
|
||||
|
||||
<table><tr><td><b>Class:</b> </td><td>class:macro</td></tr><tr><td><b>Namespace:</b> </td><td>sigil</td></tr><tr><td><b>Interface Layer:</b> </td><td>all</td></tr></table><hr/>
|
||||
<h2>sip</h2>
|
||||
<div style='margin-left: 1em;'><p><b>Data:</b> nq-n<br>
|
||||
<b>Addr:</b> -<br>
|
||||
|
|
428
doc/Glossary.txt
428
doc/Glossary.txt
|
@ -28,7 +28,7 @@ Class: class:macro | Namespace: global | Interface Layer: all
|
|||
|
||||
Provide a visual indication of a code group.
|
||||
|
||||
Class: class:macro | Namespace: prefix | Interface Layer: all
|
||||
Class: class:macro | Namespace: sigil | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
)
|
||||
|
@ -39,7 +39,7 @@ Class: class:macro | Namespace: prefix | Interface Layer: all
|
|||
|
||||
Provide a visual indication of a code group.
|
||||
|
||||
Class: class:macro | Namespace: prefix | Interface Layer: all
|
||||
Class: class:macro | Namespace: sigil | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
*
|
||||
|
@ -4206,218 +4206,6 @@ Move a value from the return stack to the data stack.
|
|||
Class: class:macro | Namespace: global | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
prefix:!
|
||||
|
||||
Data: ns-
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Store a value into a variable.
|
||||
|
||||
Interpret Time:
|
||||
Store a value into the named variable.
|
||||
|
||||
Compile Time:
|
||||
Compile the code to store a value into a named variable.
|
||||
|
||||
Class: class:macro | Namespace: prefix | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
prefix:#
|
||||
|
||||
Data: s-n
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Process token as a number.
|
||||
|
||||
Interpret Time:
|
||||
Convert the string into a number and leave on the stack.
|
||||
|
||||
Compile Time:
|
||||
Convert the string into a number and compile into the current definition as a literal.
|
||||
|
||||
Class: class:macro | Namespace: prefix | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
prefix:$
|
||||
|
||||
Data: s-c
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Process token as an ASCII character.
|
||||
|
||||
Interpret Time:
|
||||
Fetch first character from string. Leave on stack.
|
||||
|
||||
Compile Time:
|
||||
Fetch first character from the string. Compile into the current definition as literal.
|
||||
|
||||
Class: class:macro | Namespace: prefix | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
prefix:&
|
||||
|
||||
Data: s-a
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Return a pointer to a named item.
|
||||
|
||||
Interpret Time:
|
||||
Lookup name in dictionary, return contents of the xt field on the stack.
|
||||
|
||||
Compile Time:
|
||||
Lookup name in dictionary, compile code to push the contents of the xt field into the current definition.
|
||||
|
||||
Class: class:macro | Namespace: prefix | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
prefix:'
|
||||
|
||||
Data: s-s
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Process token as a string.
|
||||
|
||||
Interpret Time:
|
||||
Move string into temporary buffer. If `RewriteUnderscores` is `TRUE`, replace all instances of _ with space.
|
||||
|
||||
Compile Time:
|
||||
Move string into temporary buffer. If `RewriteUnderscores` is `TRUE`, replace all instances of _ with space. Then compile the string into the current definition.
|
||||
|
||||
Class: class:macro | Namespace: prefix | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
prefix:(
|
||||
|
||||
Data: s-
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Process token as a comment.
|
||||
|
||||
Interpret Time:
|
||||
Discard the string.
|
||||
|
||||
Compile Time:
|
||||
Discard the string.
|
||||
|
||||
Class: class:macro | Namespace: prefix | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
prefix:.
|
||||
|
||||
Data: s-
|
||||
Addr: -
|
||||
Float: -F
|
||||
|
||||
Interpret time: convert string to a floating point value. Compile time: convert string to a floating point value and compile code to push this value to the float stack.
|
||||
|
||||
Class: class:macro | Namespace: prefix | Interface Layer: rre
|
||||
------------------------------------------------------------------------
|
||||
|
||||
prefix::
|
||||
|
||||
Data: s-
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Process token as a new definition.
|
||||
|
||||
Interpret Time:
|
||||
Create a header pointing to `here` with the provided string as the name. Sets class to `class:word`.
|
||||
|
||||
Class: class:macro | Namespace: prefix | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
prefix:@
|
||||
|
||||
Data: s-n
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Fetch from a stored variable.
|
||||
|
||||
Interpret Time:
|
||||
Fetch a value from a named variable.
|
||||
|
||||
Compile Time:
|
||||
Compile the code to fetch a value from a named variable into the current definition.
|
||||
|
||||
Class: class:macro | Namespace: prefix | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
prefix:\
|
||||
|
||||
Data: s-
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Process token as an instruction bundle.
|
||||
|
||||
Interpret Time:
|
||||
Discard the string.
|
||||
|
||||
Compile Time:
|
||||
Assemble the opcodes in the string and use `,` to inline it into the current definition.
|
||||
|
||||
Class: class:macro | Namespace: prefix | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
prefix:^
|
||||
|
||||
Data: s-
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Process token as a function reference.
|
||||
|
||||
Interpret Time:
|
||||
Discard the string.
|
||||
|
||||
Compile Time:
|
||||
Comma the XT of the word into the current definition.
|
||||
|
||||
Class: class:macro | Namespace: prefix | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
prefix:`
|
||||
|
||||
Data: s-
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Process token as a bytecode.
|
||||
|
||||
Interpret Time:
|
||||
Discard the string.
|
||||
|
||||
Compile Time:
|
||||
Convert the string to a number and use `,` to inline it into the current definition.
|
||||
|
||||
Class: class:macro | Namespace: prefix | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
prefix:|
|
||||
|
||||
Data: s-
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
POSTPONE equivalent.
|
||||
|
||||
Interpret Time:
|
||||
Discard the string.
|
||||
|
||||
Compile Time:
|
||||
Convert the string to a number and use `,` to inline it into the current definition.
|
||||
|
||||
Class: class:macro | Namespace: prefix | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
primitive
|
||||
|
||||
Data: -
|
||||
|
@ -5210,6 +4998,218 @@ Peform a bitwise shift of m by n bits. If n is positive, shift right. If negativ
|
|||
Class: class:primitive | Namespace: global | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
sigil:!
|
||||
|
||||
Data: ns-
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Store a value into a variable.
|
||||
|
||||
Interpret Time:
|
||||
Store a value into the named variable.
|
||||
|
||||
Compile Time:
|
||||
Compile the code to store a value into a named variable.
|
||||
|
||||
Class: class:macro | Namespace: sigil | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
sigil:#
|
||||
|
||||
Data: s-n
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Process token as a number.
|
||||
|
||||
Interpret Time:
|
||||
Convert the string into a number and leave on the stack.
|
||||
|
||||
Compile Time:
|
||||
Convert the string into a number and compile into the current definition as a literal.
|
||||
|
||||
Class: class:macro | Namespace: sigil | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
sigil:$
|
||||
|
||||
Data: s-c
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Process token as an ASCII character.
|
||||
|
||||
Interpret Time:
|
||||
Fetch first character from string. Leave on stack.
|
||||
|
||||
Compile Time:
|
||||
Fetch first character from the string. Compile into the current definition as literal.
|
||||
|
||||
Class: class:macro | Namespace: sigil | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
sigil:&
|
||||
|
||||
Data: s-a
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Return a pointer to a named item.
|
||||
|
||||
Interpret Time:
|
||||
Lookup name in dictionary, return contents of the xt field on the stack.
|
||||
|
||||
Compile Time:
|
||||
Lookup name in dictionary, compile code to push the contents of the xt field into the current definition.
|
||||
|
||||
Class: class:macro | Namespace: sigil | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
sigil:'
|
||||
|
||||
Data: s-s
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Process token as a string.
|
||||
|
||||
Interpret Time:
|
||||
Move string into temporary buffer. If `RewriteUnderscores` is `TRUE`, replace all instances of _ with space.
|
||||
|
||||
Compile Time:
|
||||
Move string into temporary buffer. If `RewriteUnderscores` is `TRUE`, replace all instances of _ with space. Then compile the string into the current definition.
|
||||
|
||||
Class: class:macro | Namespace: sigil | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
sigil:(
|
||||
|
||||
Data: s-
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Process token as a comment.
|
||||
|
||||
Interpret Time:
|
||||
Discard the string.
|
||||
|
||||
Compile Time:
|
||||
Discard the string.
|
||||
|
||||
Class: class:macro | Namespace: sigil | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
sigil:.
|
||||
|
||||
Data: s-
|
||||
Addr: -
|
||||
Float: -F
|
||||
|
||||
Interpret time: convert string to a floating point value. Compile time: convert string to a floating point value and compile code to push this value to the float stack.
|
||||
|
||||
Class: class:macro | Namespace: sigil | Interface Layer: rre
|
||||
------------------------------------------------------------------------
|
||||
|
||||
sigil::
|
||||
|
||||
Data: s-
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Process token as a new definition.
|
||||
|
||||
Interpret Time:
|
||||
Create a header pointing to `here` with the provided string as the name. Sets class to `class:word`.
|
||||
|
||||
Class: class:macro | Namespace: sigil | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
sigil:@
|
||||
|
||||
Data: s-n
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Fetch from a stored variable.
|
||||
|
||||
Interpret Time:
|
||||
Fetch a value from a named variable.
|
||||
|
||||
Compile Time:
|
||||
Compile the code to fetch a value from a named variable into the current definition.
|
||||
|
||||
Class: class:macro | Namespace: sigil | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
sigil:\
|
||||
|
||||
Data: s-
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Process token as an instruction bundle.
|
||||
|
||||
Interpret Time:
|
||||
Discard the string.
|
||||
|
||||
Compile Time:
|
||||
Assemble the opcodes in the string and use `,` to inline it into the current definition.
|
||||
|
||||
Class: class:macro | Namespace: sigil | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
sigil:^
|
||||
|
||||
Data: s-
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Process token as a function reference.
|
||||
|
||||
Interpret Time:
|
||||
Discard the string.
|
||||
|
||||
Compile Time:
|
||||
Comma the XT of the word into the current definition.
|
||||
|
||||
Class: class:macro | Namespace: sigil | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
sigil:`
|
||||
|
||||
Data: s-
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Process token as a bytecode.
|
||||
|
||||
Interpret Time:
|
||||
Discard the string.
|
||||
|
||||
Compile Time:
|
||||
Convert the string to a number and use `,` to inline it into the current definition.
|
||||
|
||||
Class: class:macro | Namespace: sigil | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
sigil:|
|
||||
|
||||
Data: s-
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
POSTPONE equivalent.
|
||||
|
||||
Interpret Time:
|
||||
Discard the string.
|
||||
|
||||
Compile Time:
|
||||
Convert the string to a number and use `,` to inline it into the current definition.
|
||||
|
||||
Class: class:macro | Namespace: sigil | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
sip
|
||||
|
||||
Data: nq-n
|
||||
|
|
|
@ -637,7 +637,7 @@ name it:
|
|||
:palindrome? dup s:reverse s:eq? ;
|
||||
```
|
||||
|
||||
Naming uses the `:` prefix to add a new word to the dictionary.
|
||||
Naming uses the `:` sigil to add a new word to the dictionary.
|
||||
The words that make up the definition are then placed, with a
|
||||
final word (`;`) ending the definition. We can then use this:
|
||||
|
||||
|
@ -661,12 +661,12 @@ Input is divided into a series of whitespace delimited tokens.
|
|||
Each of these is then processed individually. There are no
|
||||
parsing words in RETRO.
|
||||
|
||||
Tokens may have a single character *prefix*, which RETRO will
|
||||
Tokens may have a single character *sigil*, which RETRO will
|
||||
use to decide how to process the token.
|
||||
|
||||
## Prefixes
|
||||
## Sigils
|
||||
|
||||
Prefixes are single characters added to the start of a token
|
||||
Sigils are single characters added to the start of a token
|
||||
to guide the compiler. The use of these is a major way in
|
||||
which RETRO differs from traditional Forth.
|
||||
|
||||
|
@ -696,24 +696,24 @@ like:
|
|||
In RETRO, the interpret process is basically:
|
||||
|
||||
get token
|
||||
does the first character match a `prefix:` word?
|
||||
yes: pass the token to the prefix handler
|
||||
does the first character match a `sigil:` word?
|
||||
yes: pass the token to the sigil handler
|
||||
no: is token a word in the dictionary?
|
||||
yes: push the XT to the stack and call the
|
||||
class handler
|
||||
no: report an error ("not found")
|
||||
|
||||
All of the actual logic for how to deal with tokens is moved
|
||||
to the individual prefix handlers, and the logic for handling
|
||||
to the individual sigil handlers, and the logic for handling
|
||||
words is moved to word class handlers.
|
||||
|
||||
This means that prefixes are used for a lot of things. Numbers?
|
||||
Handled by a `#` prefix. Strings? Use the `'` prefix. Comments?
|
||||
Use `(`. Making a new word? Use the `:` prefix.
|
||||
This means that sigils are used for a lot of things. Numbers?
|
||||
Handled by a `#` sigil. Strings? Use the `'` sigil. Comments?
|
||||
Use `(`. Making a new word? Use the `:` sigil.
|
||||
|
||||
The major prefixes are:
|
||||
The major sigils are:
|
||||
|
||||
| Prefix | Used For |
|
||||
| Sigil | Used For |
|
||||
| ------ | ----------------------------- |
|
||||
| @ | Fetch from variable |
|
||||
| ! | Store into variable |
|
||||
|
@ -724,7 +724,7 @@ The major prefixes are:
|
|||
| ( | Comments |
|
||||
| : | Define a word |
|
||||
|
||||
The individual prefixes will be covered in more detail in the
|
||||
The individual sigils will be covered in more detail in the
|
||||
later chapters on working with different data types.
|
||||
|
||||
## Word Classes
|
||||
|
@ -1083,7 +1083,7 @@ Word names in RETRO generally follow the following conventions.
|
|||
|
||||
* Readability is important
|
||||
* Be consistent
|
||||
* Don't use a prefix as the first character of a name
|
||||
* Don't use a sigil as the first character of a name
|
||||
* Don't use underscores in word names
|
||||
* Use short names for indices
|
||||
* Word names start with a `-` for "not"
|
||||
|
@ -1138,7 +1138,7 @@ The common namespaces are:
|
|||
| err: | Words for handling errors |
|
||||
| io: | General I/O words |
|
||||
| n: | Words operating on numeric data |
|
||||
| prefix: | Contains prefix handlers |
|
||||
| sigil: | Contains sigil handlers |
|
||||
| s: | Words operating on string data |
|
||||
| v: | Words operating on variables |
|
||||
| file: | File I/O words |
|
||||
|
@ -1147,15 +1147,15 @@ The common namespaces are:
|
|||
|
||||
## Tips
|
||||
|
||||
### Don't Start Names With Prefix Characters
|
||||
### Don't Start Names With Sigil Characters
|
||||
|
||||
Avoid using a prefix as the first character of a word name. RETRO
|
||||
will look for prefixes first, this will prevent direct use of
|
||||
Avoid using a sigil as the first character of a word name. RETRO
|
||||
will look for sigils first, this will prevent direct use of
|
||||
the work in question.
|
||||
|
||||
To find a list of prefix characters, do:
|
||||
To find a list of sigil characters, do:
|
||||
|
||||
'prefix: d:words-with
|
||||
'sigil: d:words-with
|
||||
|
||||
### Don't Use Underscores
|
||||
|
||||
|
@ -1441,7 +1441,7 @@ Instead of:
|
|||
|
||||
i dudumu..
|
||||
|
||||
The runtime assembler also provides three prefixes for use in
|
||||
The runtime assembler also provides three sigils for use in
|
||||
inlining machine code into a definition. These are:
|
||||
|
||||
\ Treat token as an assembly sequence
|
||||
|
@ -1618,9 +1618,9 @@ buffer:start s:put nl
|
|||
|
||||
RETRO provides words for working with ASCII characters.
|
||||
|
||||
## Prefix
|
||||
## Sigil
|
||||
|
||||
Character constants are returned using the `$` prefix.
|
||||
Character constants are returned using the `$` sigil.
|
||||
|
||||
## Namespace
|
||||
|
||||
|
@ -1812,7 +1812,7 @@ precision (1 bit for the sign, 11 bits for the exponent, and
|
|||
the remaining 52 bits for the value), i.e. 15 decimal digits
|
||||
of precision.
|
||||
|
||||
## Prefix
|
||||
## Sigil
|
||||
|
||||
Floating point numbers start with a `.`
|
||||
|
||||
|
@ -2213,9 +2213,9 @@ two forms.
|
|||
|
||||
Numbers in RETRO are signed integers.
|
||||
|
||||
## Token Prefix
|
||||
## Sigil
|
||||
|
||||
All numbers start with a `#` prefix.
|
||||
All numbers start with a `#` sigil.
|
||||
|
||||
## Namespace
|
||||
|
||||
|
@ -2294,9 +2294,9 @@ To display a number, use `n:put`.
|
|||
|
||||
# Working With Pointers
|
||||
|
||||
## Prefix
|
||||
## Sigil
|
||||
|
||||
Pointers are returned by the `&` prefix.
|
||||
Pointers are returned by the `&` sigil.
|
||||
|
||||
## Examples
|
||||
|
||||
|
@ -2550,7 +2550,7 @@ strings can contain UTF8 encoded data if the host platform
|
|||
allows. Words like `s:length` will return the number of bytes,
|
||||
not the number of logical characters in this case.
|
||||
|
||||
## Prefix
|
||||
## Sigil
|
||||
|
||||
Strings begin with a single `'`.
|
||||
|
||||
|
@ -3746,7 +3746,7 @@ listener:
|
|||
stack_push(1024);
|
||||
execute("interpret", memory[2]);
|
||||
|
||||
The `interpret` word handles things like prefixes, so this is
|
||||
The `interpret` word handles things like sigils, so this is
|
||||
needed if you want to run something that needs those.
|
||||
|
||||
# Historical Papers and Notes
|
||||
|
@ -4103,7 +4103,7 @@ Sources:
|
|||
- http://forth.works/c812416f397af11db58e97388a3238f2
|
||||
- gopher://forth.works/0/c812416f397af11db58e97388a3238f2
|
||||
|
||||
## Prefixes as a Language Element
|
||||
## Sigils as a Language Element
|
||||
|
||||
A big change in RETRO 12 was the elimination of the traditional
|
||||
parser from the language. This was a sacrifice due to the lack
|
||||
|
@ -4115,26 +4115,26 @@ And so `interpret` operates only on the current token. The core
|
|||
language does not track what came before or attempt to guess at
|
||||
what might come in the future.
|
||||
|
||||
This leads into the prefixes. RETRO 11 had a complicated system
|
||||
for prefixes, with different types of prefixes for words that
|
||||
This leads into the sigils. RETRO 11 had a complicated system
|
||||
for sigils, with different types of sigilss for words that
|
||||
parsed ahead (e.g., strings) and words that operated on the
|
||||
current token (e.g., `@`). RETRO 12 eliminates all of these in
|
||||
favor of just having a single prefix model.
|
||||
favor of just having a single sigil model.
|
||||
|
||||
The first thing `interpret` does is look to see if the first
|
||||
character in a token matches a `prefix:` word. If it does, it
|
||||
passes the rest of the token as a string pointer to the prefix
|
||||
specific handler to deal with. If there is no valid prefix
|
||||
character in a token matches a `sigil:` word. If it does, it
|
||||
passes the rest of the token as a string pointer to the sigil
|
||||
specific handler to deal with. If there is no valid sigil
|
||||
found, it tries to find it in the dictionary. Assuming that it
|
||||
finds the words, it passes the `d:xt` field to the handler that
|
||||
`d:class` points to. Otherwise it calls `err:notfound`.
|
||||
|
||||
This has an important implication: *words can not reliably
|
||||
have names that start with a prefix character.*
|
||||
have names that start with a sigil character.*
|
||||
|
||||
It also simplifies things. Anything that would normally parse
|
||||
becomes a prefix handler. So creating a new word? Use the `:`
|
||||
prefix. Strings? Use `'`. Pointers? Try `&`. And so on. E.g.,
|
||||
becomes a sigil handler. So creating a new word? Use the `:`
|
||||
sigil. Strings? Use `'`. Pointers? Try `&`. And so on. E.g.,
|
||||
|
||||
In ANS | In RETRO
|
||||
: foo ... ; | :foo ... ;
|
||||
|
@ -4142,12 +4142,12 @@ prefix. Strings? Use `'`. Pointers? Try `&`. And so on. E.g.,
|
|||
: bar ... ['] foo ; | :bar ... &foo ;
|
||||
s" hello world!" | 'hello_world!
|
||||
|
||||
If you are familiar with ColorForth, prefixes are a similar
|
||||
If you are familiar with ColorForth, sigils are a similar
|
||||
idea to colors, but can be defined by the user as normal words.
|
||||
|
||||
After doing this for quite a while I rather like it. I can see
|
||||
why Chuck Moore eventually went towards ColorForth as using
|
||||
color (or prefixes in my case) does simplify the implementation
|
||||
color (or sigils in my case) does simplify the implementation
|
||||
in many ways.
|
||||
|
||||
## On The Kernel Wordset
|
||||
|
@ -4187,14 +4187,14 @@ Compiler & Interpreter
|
|||
Compiler Heap ; [ ] Dictionary
|
||||
d:link d:class d:xt d:name d:add-header
|
||||
class:word class:primitive class:data class:macro
|
||||
prefix:: prefix:# prefix:& prefix:$
|
||||
sigil:: sigil:# sigil:& sigil:$
|
||||
interpret d:lookup err:notfound
|
||||
|
||||
Assembler
|
||||
|
||||
i d r
|
||||
|
||||
I *could* slightly reduce this. The $ prefix could be defined in
|
||||
I *could* slightly reduce this. The $ sigil could be defined in
|
||||
higher level code, and I don't strictly *need* to expose the
|
||||
`fetch-next` and `store-next` here. But since the are already
|
||||
implemented as dependencies of the words in the kernel, it would
|
||||
|
@ -4440,9 +4440,9 @@ Consider:
|
|||
'test_name var
|
||||
#188 !test_name
|
||||
|
||||
In the first case, the `:` prefix handles the token, so the
|
||||
In the first case, the `:` sigil handles the token, so the
|
||||
underscore is not remapped to a space, creating a word name as
|
||||
`hello_msg`. But in the second, the `'` prefix remaps the
|
||||
`hello_msg`. But in the second, the `'` sigil remaps the
|
||||
underscore to a space, giving a variable name of `test name`.
|
||||
In the third line, the name lookup will fail as `test_name` is
|
||||
not defined, so the store will be done to an incorrect address.
|
||||
|
|
|
@ -32,7 +32,7 @@ name it:
|
|||
:palindrome? dup s:reverse s:eq? ;
|
||||
```
|
||||
|
||||
Naming uses the `:` prefix to add a new word to the dictionary.
|
||||
Naming uses the `:` sigil to add a new word to the dictionary.
|
||||
The words that make up the definition are then placed, with a
|
||||
final word (`;`) ending the definition. We can then use this:
|
||||
|
||||
|
|
|
@ -11,12 +11,12 @@ Input is divided into a series of whitespace delimited tokens.
|
|||
Each of these is then processed individually. There are no
|
||||
parsing words in RETRO.
|
||||
|
||||
Tokens may have a single character *prefix*, which RETRO will
|
||||
Tokens may have a single character *sigil*, which RETRO will
|
||||
use to decide how to process the token.
|
||||
|
||||
## Prefixes
|
||||
## Sigils
|
||||
|
||||
Prefixes are single characters added to the start of a token
|
||||
Sigils are single characters added to the start of a token
|
||||
to guide the compiler. The use of these is a major way in
|
||||
which RETRO differs from traditional Forth.
|
||||
|
||||
|
@ -46,24 +46,24 @@ like:
|
|||
In RETRO, the interpret process is basically:
|
||||
|
||||
get token
|
||||
does the first character match a `prefix:` word?
|
||||
yes: pass the token to the prefix handler
|
||||
does the first character match a `sigil:` word?
|
||||
yes: pass the token to the sigil handler
|
||||
no: is token a word in the dictionary?
|
||||
yes: push the XT to the stack and call the
|
||||
class handler
|
||||
no: report an error ("not found")
|
||||
|
||||
All of the actual logic for how to deal with tokens is moved
|
||||
to the individual prefix handlers, and the logic for handling
|
||||
to the individual sigil handlers, and the logic for handling
|
||||
words is moved to word class handlers.
|
||||
|
||||
This means that prefixes are used for a lot of things. Numbers?
|
||||
Handled by a `#` prefix. Strings? Use the `'` prefix. Comments?
|
||||
Use `(`. Making a new word? Use the `:` prefix.
|
||||
This means that sigils are used for a lot of things. Numbers?
|
||||
Handled by a `#` sigil. Strings? Use the `'` sigil. Comments?
|
||||
Use `(`. Making a new word? Use the `:` sigil.
|
||||
|
||||
The major prefixes are:
|
||||
The major sigils are:
|
||||
|
||||
| Prefix | Used For |
|
||||
| Sigil | Used For |
|
||||
| ------ | ----------------------------- |
|
||||
| @ | Fetch from variable |
|
||||
| ! | Store into variable |
|
||||
|
@ -74,7 +74,7 @@ The major prefixes are:
|
|||
| ( | Comments |
|
||||
| : | Define a word |
|
||||
|
||||
The individual prefixes will be covered in more detail in the
|
||||
The individual sigils will be covered in more detail in the
|
||||
later chapters on working with different data types.
|
||||
|
||||
## Word Classes
|
||||
|
|
|
@ -28,7 +28,7 @@ Class: class:macro | Namespace: global | Interface Layer: all
|
|||
|
||||
Provide a visual indication of a code group.
|
||||
|
||||
Class: class:macro | Namespace: prefix | Interface Layer: all
|
||||
Class: class:macro | Namespace: sigil | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
)
|
||||
|
@ -39,7 +39,7 @@ Class: class:macro | Namespace: prefix | Interface Layer: all
|
|||
|
||||
Provide a visual indication of a code group.
|
||||
|
||||
Class: class:macro | Namespace: prefix | Interface Layer: all
|
||||
Class: class:macro | Namespace: sigil | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
*
|
||||
|
@ -1152,6 +1152,17 @@ Create a new string from the provided array. This string will be stored in the t
|
|||
Class: class:word | Namespace: a | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
abort
|
||||
|
||||
Data: -
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Abort execution.
|
||||
|
||||
Class: class:macro | Namespace: global | Interface Layer: rre
|
||||
------------------------------------------------------------------------
|
||||
|
||||
again
|
||||
|
||||
Data: -
|
||||
|
@ -2060,7 +2071,7 @@ d:lookup
|
|||
Addr: -
|
||||
Float: -
|
||||
|
||||
Lookup the specified name in the dictionary and return a pointer to its dictionary header. This returns zero if the word is not found.
|
||||
Lookup the specified name in the dictionary and return a pointer to its dictionary header. This returns zero if the word is not found. This also sets an internal variable ('which' in retro.muri) to the header address.
|
||||
|
||||
Class: class:word | Namespace: d | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
@ -4195,218 +4206,6 @@ Move a value from the return stack to the data stack.
|
|||
Class: class:macro | Namespace: global | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
prefix:!
|
||||
|
||||
Data: ns-
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Store a value into a variable.
|
||||
|
||||
Interpret Time:
|
||||
Store a value into the named variable.
|
||||
|
||||
Compile Time:
|
||||
Compile the code to store a value into a named variable.
|
||||
|
||||
Class: class:macro | Namespace: prefix | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
prefix:#
|
||||
|
||||
Data: s-n
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Process token as a number.
|
||||
|
||||
Interpret Time:
|
||||
Convert the string into a number and leave on the stack.
|
||||
|
||||
Compile Time:
|
||||
Convert the string into a number and compile into the current definition as a literal.
|
||||
|
||||
Class: class:macro | Namespace: prefix | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
prefix:$
|
||||
|
||||
Data: s-c
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Process token as an ASCII character.
|
||||
|
||||
Interpret Time:
|
||||
Fetch first character from string. Leave on stack.
|
||||
|
||||
Compile Time:
|
||||
Fetch first character from the string. Compile into the current definition as literal.
|
||||
|
||||
Class: class:macro | Namespace: prefix | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
prefix:&
|
||||
|
||||
Data: s-a
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Return a pointer to a named item.
|
||||
|
||||
Interpret Time:
|
||||
Lookup name in dictionary, return contents of the xt field on the stack.
|
||||
|
||||
Compile Time:
|
||||
Lookup name in dictionary, compile code to push the contents of the xt field into the current definition.
|
||||
|
||||
Class: class:macro | Namespace: prefix | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
prefix:'
|
||||
|
||||
Data: s-s
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Process token as a string.
|
||||
|
||||
Interpret Time:
|
||||
Move string into temporary buffer. If `RewriteUnderscores` is `TRUE`, replace all instances of _ with space.
|
||||
|
||||
Compile Time:
|
||||
Move string into temporary buffer. If `RewriteUnderscores` is `TRUE`, replace all instances of _ with space. Then compile the string into the current definition.
|
||||
|
||||
Class: class:macro | Namespace: prefix | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
prefix:(
|
||||
|
||||
Data: s-
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Process token as a comment.
|
||||
|
||||
Interpret Time:
|
||||
Discard the string.
|
||||
|
||||
Compile Time:
|
||||
Discard the string.
|
||||
|
||||
Class: class:macro | Namespace: prefix | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
prefix:.
|
||||
|
||||
Data: s-
|
||||
Addr: -
|
||||
Float: -F
|
||||
|
||||
Interpret time: convert string to a floating point value. Compile time: convert string to a floating point value and compile code to push this value to the float stack.
|
||||
|
||||
Class: class:macro | Namespace: prefix | Interface Layer: rre
|
||||
------------------------------------------------------------------------
|
||||
|
||||
prefix::
|
||||
|
||||
Data: s-
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Process token as a new definition.
|
||||
|
||||
Interpret Time:
|
||||
Create a header pointing to `here` with the provided string as the name. Sets class to `class:word`.
|
||||
|
||||
Class: class:macro | Namespace: prefix | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
prefix:@
|
||||
|
||||
Data: s-n
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Fetch from a stored variable.
|
||||
|
||||
Interpret Time:
|
||||
Fetch a value from a named variable.
|
||||
|
||||
Compile Time:
|
||||
Compile the code to fetch a value from a named variable into the current definition.
|
||||
|
||||
Class: class:macro | Namespace: prefix | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
prefix:\
|
||||
|
||||
Data: s-
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Process token as an instruction bundle.
|
||||
|
||||
Interpret Time:
|
||||
Discard the string.
|
||||
|
||||
Compile Time:
|
||||
Assemble the opcodes in the string and use `,` to inline it into the current definition.
|
||||
|
||||
Class: class:macro | Namespace: prefix | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
prefix:^
|
||||
|
||||
Data: s-
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Process token as a function reference.
|
||||
|
||||
Interpret Time:
|
||||
Discard the string.
|
||||
|
||||
Compile Time:
|
||||
Comma the XT of the word into the current definition.
|
||||
|
||||
Class: class:macro | Namespace: prefix | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
prefix:`
|
||||
|
||||
Data: s-
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Process token as a bytecode.
|
||||
|
||||
Interpret Time:
|
||||
Discard the string.
|
||||
|
||||
Compile Time:
|
||||
Convert the string to a number and use `,` to inline it into the current definition.
|
||||
|
||||
Class: class:macro | Namespace: prefix | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
prefix:|
|
||||
|
||||
Data: s-
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
POSTPONE equivalent.
|
||||
|
||||
Interpret Time:
|
||||
Discard the string.
|
||||
|
||||
Compile Time:
|
||||
Convert the string to a number and use `,` to inline it into the current definition.
|
||||
|
||||
Class: class:macro | Namespace: prefix | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
primitive
|
||||
|
||||
Data: -
|
||||
|
@ -5148,6 +4947,17 @@ Discard remaining lines in the file currently being evaluated. This only works w
|
|||
Class: class:word | Namespace: sys | Interface Layer: rre
|
||||
------------------------------------------------------------------------
|
||||
|
||||
script:ignore-to-eol
|
||||
|
||||
Data: -
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Discard remaining tokens in the current line. This only works when including a file, not at the interpreter.
|
||||
|
||||
Class: class:word | Namespace: sys | Interface Layer: rre
|
||||
------------------------------------------------------------------------
|
||||
|
||||
script:name
|
||||
|
||||
Data: -s
|
||||
|
@ -5188,6 +4998,218 @@ Peform a bitwise shift of m by n bits. If n is positive, shift right. If negativ
|
|||
Class: class:primitive | Namespace: global | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
sigil:!
|
||||
|
||||
Data: ns-
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Store a value into a variable.
|
||||
|
||||
Interpret Time:
|
||||
Store a value into the named variable.
|
||||
|
||||
Compile Time:
|
||||
Compile the code to store a value into a named variable.
|
||||
|
||||
Class: class:macro | Namespace: sigil | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
sigil:#
|
||||
|
||||
Data: s-n
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Process token as a number.
|
||||
|
||||
Interpret Time:
|
||||
Convert the string into a number and leave on the stack.
|
||||
|
||||
Compile Time:
|
||||
Convert the string into a number and compile into the current definition as a literal.
|
||||
|
||||
Class: class:macro | Namespace: sigil | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
sigil:$
|
||||
|
||||
Data: s-c
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Process token as an ASCII character.
|
||||
|
||||
Interpret Time:
|
||||
Fetch first character from string. Leave on stack.
|
||||
|
||||
Compile Time:
|
||||
Fetch first character from the string. Compile into the current definition as literal.
|
||||
|
||||
Class: class:macro | Namespace: sigil | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
sigil:&
|
||||
|
||||
Data: s-a
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Return a pointer to a named item.
|
||||
|
||||
Interpret Time:
|
||||
Lookup name in dictionary, return contents of the xt field on the stack.
|
||||
|
||||
Compile Time:
|
||||
Lookup name in dictionary, compile code to push the contents of the xt field into the current definition.
|
||||
|
||||
Class: class:macro | Namespace: sigil | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
sigil:'
|
||||
|
||||
Data: s-s
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Process token as a string.
|
||||
|
||||
Interpret Time:
|
||||
Move string into temporary buffer. If `RewriteUnderscores` is `TRUE`, replace all instances of _ with space.
|
||||
|
||||
Compile Time:
|
||||
Move string into temporary buffer. If `RewriteUnderscores` is `TRUE`, replace all instances of _ with space. Then compile the string into the current definition.
|
||||
|
||||
Class: class:macro | Namespace: sigil | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
sigil:(
|
||||
|
||||
Data: s-
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Process token as a comment.
|
||||
|
||||
Interpret Time:
|
||||
Discard the string.
|
||||
|
||||
Compile Time:
|
||||
Discard the string.
|
||||
|
||||
Class: class:macro | Namespace: sigil | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
sigil:.
|
||||
|
||||
Data: s-
|
||||
Addr: -
|
||||
Float: -F
|
||||
|
||||
Interpret time: convert string to a floating point value. Compile time: convert string to a floating point value and compile code to push this value to the float stack.
|
||||
|
||||
Class: class:macro | Namespace: sigil | Interface Layer: rre
|
||||
------------------------------------------------------------------------
|
||||
|
||||
sigil::
|
||||
|
||||
Data: s-
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Process token as a new definition.
|
||||
|
||||
Interpret Time:
|
||||
Create a header pointing to `here` with the provided string as the name. Sets class to `class:word`.
|
||||
|
||||
Class: class:macro | Namespace: sigil | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
sigil:@
|
||||
|
||||
Data: s-n
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Fetch from a stored variable.
|
||||
|
||||
Interpret Time:
|
||||
Fetch a value from a named variable.
|
||||
|
||||
Compile Time:
|
||||
Compile the code to fetch a value from a named variable into the current definition.
|
||||
|
||||
Class: class:macro | Namespace: sigil | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
sigil:\
|
||||
|
||||
Data: s-
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Process token as an instruction bundle.
|
||||
|
||||
Interpret Time:
|
||||
Discard the string.
|
||||
|
||||
Compile Time:
|
||||
Assemble the opcodes in the string and use `,` to inline it into the current definition.
|
||||
|
||||
Class: class:macro | Namespace: sigil | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
sigil:^
|
||||
|
||||
Data: s-
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Process token as a function reference.
|
||||
|
||||
Interpret Time:
|
||||
Discard the string.
|
||||
|
||||
Compile Time:
|
||||
Comma the XT of the word into the current definition.
|
||||
|
||||
Class: class:macro | Namespace: sigil | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
sigil:`
|
||||
|
||||
Data: s-
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Process token as a bytecode.
|
||||
|
||||
Interpret Time:
|
||||
Discard the string.
|
||||
|
||||
Compile Time:
|
||||
Convert the string to a number and use `,` to inline it into the current definition.
|
||||
|
||||
Class: class:macro | Namespace: sigil | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
sigil:|
|
||||
|
||||
Data: s-
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
POSTPONE equivalent.
|
||||
|
||||
Interpret Time:
|
||||
Discard the string.
|
||||
|
||||
Compile Time:
|
||||
Convert the string to a number and use `,` to inline it into the current definition.
|
||||
|
||||
Class: class:macro | Namespace: sigil | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
sip
|
||||
|
||||
Data: nq-n
|
||||
|
@ -5376,39 +5398,6 @@ Exchange the position of the top two items on the stack
|
|||
Class: class:primitive | Namespace: global | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
sys:argc
|
||||
|
||||
Data: -n
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Return the number of arguments passed to the program. Deprecated. Use script:arguments
|
||||
|
||||
Class: class:word | Namespace: sys | Interface Layer: rre
|
||||
------------------------------------------------------------------------
|
||||
|
||||
sys:argv
|
||||
|
||||
Data: n-s
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Given an argument number, return the argument as a string. Deprecated. Use script:get-argument instead.
|
||||
|
||||
Class: class:word | Namespace: sys | Interface Layer: rre
|
||||
------------------------------------------------------------------------
|
||||
|
||||
sys:name
|
||||
|
||||
Data: -s
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Return the filename of the program being run. Deprecated. Use script:name instead.
|
||||
|
||||
Class: class:word | Namespace: sys | Interface Layer: rre
|
||||
------------------------------------------------------------------------
|
||||
|
||||
tab
|
||||
|
||||
Data: -
|
||||
|
@ -5480,6 +5469,171 @@ Put a copy of the top item on the stack under the second one.
|
|||
Class: class:word | Namespace: global | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
ui:add-view
|
||||
|
||||
Data: s-
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Add view named `s` to the displayed views.
|
||||
|
||||
Class: class:word | Namespace: ui | Interface Layer: retro/python
|
||||
------------------------------------------------------------------------
|
||||
|
||||
ui:create-view
|
||||
|
||||
Data: ss-
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Create a new view. `s1` is the name and `s2` is the type.
|
||||
|
||||
Class: class:word | Namespace: ui | Interface Layer: retro/python
|
||||
------------------------------------------------------------------------
|
||||
|
||||
ui:get-action
|
||||
|
||||
Data: s-a
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Return the address of the Retro handler for a view's associated action.
|
||||
|
||||
Class: class:word | Namespace: ui | Interface Layer: retro/python
|
||||
------------------------------------------------------------------------
|
||||
|
||||
ui:get-position
|
||||
|
||||
Data: s-nn
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Return the row and column of the named view.
|
||||
|
||||
Class: class:word | Namespace: ui | Interface Layer: retro/python
|
||||
------------------------------------------------------------------------
|
||||
|
||||
ui:get-size
|
||||
|
||||
Data: s-nn
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Return the height and width of the named view.
|
||||
|
||||
Class: class:word | Namespace: ui | Interface Layer: retro/python
|
||||
------------------------------------------------------------------------
|
||||
|
||||
ui:get-text
|
||||
|
||||
Data: s-s
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Get the value of the text property of the named view.
|
||||
|
||||
Class: class:word | Namespace: ui | Interface Layer: retro/python
|
||||
------------------------------------------------------------------------
|
||||
|
||||
ui:get-title
|
||||
|
||||
Data: s-s
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Get the value of the title property for the named view.
|
||||
|
||||
Class: class:word | Namespace: ui | Interface Layer: retro/python
|
||||
------------------------------------------------------------------------
|
||||
|
||||
ui:operation
|
||||
|
||||
Data: ...n-
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Carry out a UI operation. Used internally by the other `ui:` words.
|
||||
|
||||
Class: class:word | Namespace: ui | Interface Layer: retro/python
|
||||
------------------------------------------------------------------------
|
||||
|
||||
ui:present
|
||||
|
||||
Data: -
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Display all views.
|
||||
|
||||
Class: class:word | Namespace: ui | Interface Layer: retro/python
|
||||
------------------------------------------------------------------------
|
||||
|
||||
ui:remove-view
|
||||
|
||||
Data: s-
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Remove view named `s` from the displayed views.
|
||||
|
||||
Class: class:word | Namespace: ui | Interface Layer: retro/python
|
||||
------------------------------------------------------------------------
|
||||
|
||||
ui:set-action
|
||||
|
||||
Data: as-
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Set the action handler for a view to the specified Retro word address.
|
||||
|
||||
Class: class:word | Namespace: ui | Interface Layer: retro/python
|
||||
------------------------------------------------------------------------
|
||||
|
||||
ui:set-position
|
||||
|
||||
Data: nns-
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Move view `s` to row `n1` and column `n2`.
|
||||
|
||||
Class: class:word | Namespace: ui | Interface Layer: retro/python
|
||||
------------------------------------------------------------------------
|
||||
|
||||
ui:set-size
|
||||
|
||||
Data: nns-
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Set view `s` to height `n1` and width `n2`.
|
||||
|
||||
Class: class:word | Namespace: ui | Interface Layer: retro/python
|
||||
------------------------------------------------------------------------
|
||||
|
||||
ui:set-text
|
||||
|
||||
Data: ss-
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Set the text property of view `s2` to `s1`.
|
||||
|
||||
Class: class:word | Namespace: ui | Interface Layer: retro/python
|
||||
------------------------------------------------------------------------
|
||||
|
||||
ui:set-title
|
||||
|
||||
Data: ss-
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Set the title property of view `s2` to `s1`.
|
||||
|
||||
Class: class:word | Namespace: ui | Interface Layer: retro/python
|
||||
------------------------------------------------------------------------
|
||||
|
||||
unhook
|
||||
|
||||
Data: a-
|
||||
|
@ -5663,6 +5817,22 @@ Close a pipe.
|
|||
Class: class:word | Namespace: unix | Interface Layer: rre
|
||||
------------------------------------------------------------------------
|
||||
|
||||
unix:pipe
|
||||
|
||||
Data: s-
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Takes a string with a Unix command line and run it in a pipe, returning a new string with the first line of the output from the pipe.
|
||||
|
||||
Class: class:word | Namespace: unix | Interface Layer: rre
|
||||
|
||||
Example #1:
|
||||
|
||||
'ls_-l unix:pipe s:put nl
|
||||
|
||||
------------------------------------------------------------------------
|
||||
|
||||
unix:popen
|
||||
|
||||
Data: sn-n
|
||||
|
|
|
@ -63,5 +63,5 @@ listener:
|
|||
stack_push(1024);
|
||||
execute("interpret", memory[2]);
|
||||
|
||||
The `interpret` word handles things like prefixes, so this is
|
||||
The `interpret` word handles things like sigils, so this is
|
||||
needed if you want to run something that needs those.
|
||||
|
|
|
@ -35,14 +35,14 @@ Compiler & Interpreter
|
|||
Compiler Heap ; [ ] Dictionary
|
||||
d:link d:class d:xt d:name d:add-header
|
||||
class:word class:primitive class:data class:macro
|
||||
prefix:: prefix:# prefix:& prefix:$
|
||||
sigil:: sigil:# sigil:& sigil:$
|
||||
interpret d:lookup err:notfound
|
||||
|
||||
Assembler
|
||||
|
||||
i d r
|
||||
|
||||
I *could* slightly reduce this. The $ prefix could be defined in
|
||||
I *could* slightly reduce this. The $ sigil could be defined in
|
||||
higher level code, and I don't strictly *need* to expose the
|
||||
`fetch-next` and `store-next` here. But since the are already
|
||||
implemented as dependencies of the words in the kernel, it would
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
## Prefixes as a Language Element
|
||||
## Sigils as a Language Element
|
||||
|
||||
A big change in RETRO 12 was the elimination of the traditional
|
||||
parser from the language. This was a sacrifice due to the lack
|
||||
|
@ -10,26 +10,26 @@ And so `interpret` operates only on the current token. The core
|
|||
language does not track what came before or attempt to guess at
|
||||
what might come in the future.
|
||||
|
||||
This leads into the prefixes. RETRO 11 had a complicated system
|
||||
for prefixes, with different types of prefixes for words that
|
||||
This leads into the sigils. RETRO 11 had a complicated system
|
||||
for sigils, with different types of sigilss for words that
|
||||
parsed ahead (e.g., strings) and words that operated on the
|
||||
current token (e.g., `@`). RETRO 12 eliminates all of these in
|
||||
favor of just having a single prefix model.
|
||||
favor of just having a single sigil model.
|
||||
|
||||
The first thing `interpret` does is look to see if the first
|
||||
character in a token matches a `prefix:` word. If it does, it
|
||||
passes the rest of the token as a string pointer to the prefix
|
||||
specific handler to deal with. If there is no valid prefix
|
||||
character in a token matches a `sigil:` word. If it does, it
|
||||
passes the rest of the token as a string pointer to the sigil
|
||||
specific handler to deal with. If there is no valid sigil
|
||||
found, it tries to find it in the dictionary. Assuming that it
|
||||
finds the words, it passes the `d:xt` field to the handler that
|
||||
`d:class` points to. Otherwise it calls `err:notfound`.
|
||||
|
||||
This has an important implication: *words can not reliably
|
||||
have names that start with a prefix character.*
|
||||
have names that start with a sigil character.*
|
||||
|
||||
It also simplifies things. Anything that would normally parse
|
||||
becomes a prefix handler. So creating a new word? Use the `:`
|
||||
prefix. Strings? Use `'`. Pointers? Try `&`. And so on. E.g.,
|
||||
becomes a sigil handler. So creating a new word? Use the `:`
|
||||
sigil. Strings? Use `'`. Pointers? Try `&`. And so on. E.g.,
|
||||
|
||||
In ANS | In RETRO
|
||||
: foo ... ; | :foo ... ;
|
||||
|
@ -37,10 +37,10 @@ prefix. Strings? Use `'`. Pointers? Try `&`. And so on. E.g.,
|
|||
: bar ... ['] foo ; | :bar ... &foo ;
|
||||
s" hello world!" | 'hello_world!
|
||||
|
||||
If you are familiar with ColorForth, prefixes are a similar
|
||||
If you are familiar with ColorForth, sigils are a similar
|
||||
idea to colors, but can be defined by the user as normal words.
|
||||
|
||||
After doing this for quite a while I rather like it. I can see
|
||||
why Chuck Moore eventually went towards ColorForth as using
|
||||
color (or prefixes in my case) does simplify the implementation
|
||||
color (or sigils in my case) does simplify the implementation
|
||||
in many ways.
|
||||
|
|
|
@ -13,9 +13,9 @@ Consider:
|
|||
'test_name var
|
||||
#188 !test_name
|
||||
|
||||
In the first case, the `:` prefix handles the token, so the
|
||||
In the first case, the `:` sigil handles the token, so the
|
||||
underscore is not remapped to a space, creating a word name as
|
||||
`hello_msg`. But in the second, the `'` prefix remaps the
|
||||
`hello_msg`. But in the second, the `'` sigil remaps the
|
||||
underscore to a space, giving a variable name of `test name`.
|
||||
In the third line, the name lookup will fail as `test_name` is
|
||||
not defined, so the store will be done to an incorrect address.
|
||||
|
|
|
@ -100,7 +100,7 @@ Instead of:
|
|||
|
||||
i dudumu..
|
||||
|
||||
The runtime assembler also provides three prefixes for use in
|
||||
The runtime assembler also provides three sigils for use in
|
||||
inlining machine code into a definition. These are:
|
||||
|
||||
\ Treat token as an assembly sequence
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
RETRO provides words for working with ASCII characters.
|
||||
|
||||
## Prefix
|
||||
## Sigil
|
||||
|
||||
Character constants are returned using the `$` prefix.
|
||||
Character constants are returned using the `$` sigil.
|
||||
|
||||
## Namespace
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ precision (1 bit for the sign, 11 bits for the exponent, and
|
|||
the remaining 52 bits for the value), i.e. 15 decimal digits
|
||||
of precision.
|
||||
|
||||
## Prefix
|
||||
## Sigil
|
||||
|
||||
Floating point numbers start with a `.`
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ Word names in RETRO generally follow the following conventions.
|
|||
|
||||
* Readability is important
|
||||
* Be consistent
|
||||
* Don't use a prefix as the first character of a name
|
||||
* Don't use a sigil as the first character of a name
|
||||
* Don't use underscores in word names
|
||||
* Use short names for indices
|
||||
* Word names start with a `-` for "not"
|
||||
|
@ -61,7 +61,7 @@ The common namespaces are:
|
|||
| err: | Words for handling errors |
|
||||
| io: | General I/O words |
|
||||
| n: | Words operating on numeric data |
|
||||
| prefix: | Contains prefix handlers |
|
||||
| sigil: | Contains sigil handlers |
|
||||
| s: | Words operating on string data |
|
||||
| v: | Words operating on variables |
|
||||
| file: | File I/O words |
|
||||
|
@ -70,15 +70,15 @@ The common namespaces are:
|
|||
|
||||
## Tips
|
||||
|
||||
### Don't Start Names With Prefix Characters
|
||||
### Don't Start Names With Sigil Characters
|
||||
|
||||
Avoid using a prefix as the first character of a word name. RETRO
|
||||
will look for prefixes first, this will prevent direct use of
|
||||
Avoid using a sigil as the first character of a word name. RETRO
|
||||
will look for sigils first, this will prevent direct use of
|
||||
the work in question.
|
||||
|
||||
To find a list of prefix characters, do:
|
||||
To find a list of sigil characters, do:
|
||||
|
||||
'prefix: d:words-with
|
||||
'sigil: d:words-with
|
||||
|
||||
### Don't Use Underscores
|
||||
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
Numbers in RETRO are signed integers.
|
||||
|
||||
## Token Prefix
|
||||
## Sigil
|
||||
|
||||
All numbers start with a `#` prefix.
|
||||
All numbers start with a `#` sigil.
|
||||
|
||||
## Namespace
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# Working With Pointers
|
||||
|
||||
## Prefix
|
||||
## Sigil
|
||||
|
||||
Pointers are returned by the `&` prefix.
|
||||
Pointers are returned by the `&` sigil.
|
||||
|
||||
## Examples
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ strings can contain UTF8 encoded data if the host platform
|
|||
allows. Words like `s:length` will return the number of bytes,
|
||||
not the number of logical characters in this case.
|
||||
|
||||
## Prefix
|
||||
## Sigil
|
||||
|
||||
Strings begin with a single `'`.
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ name it:
|
|||
<br/><br/>
|
||||
<span class='codeblock'><span class="tt">```</span><br/><span class="tt"><span class='colon'>:palindrome?</span> <span class='prim'>dup</span> s:reverse s:eq? <span class='imm'>;</span> </span><br/>
|
||||
<span class="tt">```</span></span><br/><br/>
|
||||
Naming uses the <span class="tt">:</span> prefix to add a new word to the dictionary.
|
||||
Naming uses the <span class="tt">:</span> sigil to add a new word to the dictionary.
|
||||
The words that make up the definition are then placed, with a
|
||||
final word (<span class="tt">;</span>) ending the definition. We can then use this:
|
||||
<br/><br/>
|
||||
|
|
|
@ -56,12 +56,12 @@ Input is divided into a series of whitespace delimited tokens.
|
|||
Each of these is then processed individually. There are no
|
||||
parsing words in RETRO.
|
||||
<br/><br/>
|
||||
Tokens may have a single character <strong>prefix</strong>, which RETRO will
|
||||
Tokens may have a single character <strong>sigil</strong>, which RETRO will
|
||||
use to decide how to process the token.
|
||||
<br/><br/>
|
||||
<span class="h2">Prefixes</span>
|
||||
<span class="h2">Sigils</span>
|
||||
<br/><br/>
|
||||
Prefixes are single characters added to the start of a token
|
||||
Sigils are single characters added to the start of a token
|
||||
to guide the compiler. The use of these is a major way in
|
||||
which RETRO differs from traditional Forth.
|
||||
<br/><br/>
|
||||
|
@ -91,24 +91,24 @@ like:
|
|||
In RETRO, the interpret process is basically:
|
||||
<br/><br/>
|
||||
<tt class='indentedcode'>get token</tt>
|
||||
<tt class='indentedcode'>does the first character match a `prefix:` word?</tt>
|
||||
<tt class='indentedcode'> yes: pass the token to the prefix handler</tt>
|
||||
<tt class='indentedcode'>does the first character match a `sigil:` word?</tt>
|
||||
<tt class='indentedcode'> yes: pass the token to the sigil handler</tt>
|
||||
<tt class='indentedcode'> no: is token a word in the dictionary?</tt>
|
||||
<tt class='indentedcode'> yes: push the XT to the stack and call the</tt>
|
||||
<tt class='indentedcode'> class handler</tt>
|
||||
<tt class='indentedcode'> no: report an error ("not found")</tt>
|
||||
<br/><br/>
|
||||
All of the actual logic for how to deal with tokens is moved
|
||||
to the individual prefix handlers, and the logic for handling
|
||||
to the individual sigil handlers, and the logic for handling
|
||||
words is moved to word class handlers.
|
||||
<br/><br/>
|
||||
This means that prefixes are used for a lot of things. Numbers?
|
||||
Handled by a <span class="tt">#</span> prefix. Strings? Use the <span class="tt">'</span> prefix. Comments?
|
||||
Use <span class="tt">(</span>. Making a new word? Use the <span class="tt">:</span> prefix.
|
||||
This means that sigils are used for a lot of things. Numbers?
|
||||
Handled by a <span class="tt">#</span> sigil. Strings? Use the <span class="tt">'</span> sigil. Comments?
|
||||
Use <span class="tt">(</span>. Making a new word? Use the <span class="tt">:</span> sigil.
|
||||
<br/><br/>
|
||||
The major prefixes are:
|
||||
The major sigils are:
|
||||
<br/><br/>
|
||||
<tt class='indentedcode'>| Prefix | Used For |</tt>
|
||||
<tt class='indentedcode'>| Sigil | Used For |</tt>
|
||||
<tt class='indentedcode'>| ------ | ----------------------------- |</tt>
|
||||
<tt class='indentedcode'>| @ | Fetch from variable |</tt>
|
||||
<tt class='indentedcode'>| ! | Store into variable |</tt>
|
||||
|
@ -119,7 +119,7 @@ The major prefixes are:
|
|||
<tt class='indentedcode'>| ( | Comments |</tt>
|
||||
<tt class='indentedcode'>| : | Define a word |</tt>
|
||||
<br/><br/>
|
||||
The individual prefixes will be covered in more detail in the
|
||||
The individual sigils will be covered in more detail in the
|
||||
later chapters on working with different data types.
|
||||
<br/><br/>
|
||||
<span class="h2">Word Classes</span>
|
||||
|
|
|
@ -108,7 +108,7 @@ listener:
|
|||
<tt class='indentedcode'>stack_push(1024);</tt>
|
||||
<tt class='indentedcode'>execute("interpret", memory[2]);</tt>
|
||||
<br/><br/>
|
||||
The <span class="tt">interpret</span> word handles things like prefixes, so this is
|
||||
The <span class="tt">interpret</span> word handles things like sigils, so this is
|
||||
needed if you want to run something that needs those.
|
||||
</p>
|
||||
</body></html>
|
||||
|
|
|
@ -80,14 +80,14 @@ Compiler & Interpreter
|
|||
<tt class='indentedcode'>Compiler Heap ; [ ] Dictionary</tt>
|
||||
<tt class='indentedcode'>d:link d:class d:xt d:name d:add-header</tt>
|
||||
<tt class='indentedcode'>class:word class:primitive class:data class:macro</tt>
|
||||
<tt class='indentedcode'>prefix:: prefix:# prefix:& prefix:$</tt>
|
||||
<tt class='indentedcode'>sigil:: sigil:# sigil:& sigil:$</tt>
|
||||
<tt class='indentedcode'>interpret d:lookup err:notfound</tt>
|
||||
<br/><br/>
|
||||
Assembler
|
||||
<br/><br/>
|
||||
<tt class='indentedcode'>i d r</tt>
|
||||
<br/><br/>
|
||||
I <strong>could</strong> slightly reduce this. The $ prefix could be defined in
|
||||
I <strong>could</strong> slightly reduce this. The $ sigil could be defined in
|
||||
higher level code, and I don't strictly <strong>need</strong> to expose the
|
||||
<span class="tt">fetch-next</span> and <span class="tt">store-next</span> here. But since the are already
|
||||
implemented as dependencies of the words in the kernel, it would
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
.hr { display: block; height: 2px; background: #000000; }
|
||||
</style>
|
||||
</head><body>
|
||||
<p><span class="h2">Prefixes as a Language Element</span>
|
||||
<p><span class="h2">Sigils as a Language Element</span>
|
||||
<br/><br/>
|
||||
A big change in RETRO 12 was the elimination of the traditional
|
||||
parser from the language. This was a sacrifice due to the lack
|
||||
|
@ -55,26 +55,26 @@ And so <span class="tt">interpret</span> operates only on the current token. The
|
|||
language does not track what came before or attempt to guess at
|
||||
what might come in the future.
|
||||
<br/><br/>
|
||||
This leads into the prefixes. RETRO 11 had a complicated system
|
||||
for prefixes, with different types of prefixes for words that
|
||||
This leads into the sigils. RETRO 11 had a complicated system
|
||||
for sigils, with different types of sigilss for words that
|
||||
parsed ahead (e.g., strings) and words that operated on the
|
||||
current token (e.g., <span class="tt">@</span>). RETRO 12 eliminates all of these in
|
||||
favor of just having a single prefix model.
|
||||
favor of just having a single sigil model.
|
||||
<br/><br/>
|
||||
The first thing <span class="tt">interpret</span> does is look to see if the first
|
||||
character in a token matches a <span class="tt">prefix:</span> word. If it does, it
|
||||
passes the rest of the token as a string pointer to the prefix
|
||||
specific handler to deal with. If there is no valid prefix
|
||||
character in a token matches a <span class="tt">sigil:</span> word. If it does, it
|
||||
passes the rest of the token as a string pointer to the sigil
|
||||
specific handler to deal with. If there is no valid sigil
|
||||
found, it tries to find it in the dictionary. Assuming that it
|
||||
finds the words, it passes the <span class="tt">d:xt</span> field to the handler that
|
||||
<span class="tt">d:class</span> points to. Otherwise it calls <span class="tt">err:notfound</span>.
|
||||
<br/><br/>
|
||||
This has an important implication: <strong>words can not reliably
|
||||
have names that start with a prefix character.</strong>
|
||||
have names that start with a sigil character.</strong>
|
||||
<br/><br/>
|
||||
It also simplifies things. Anything that would normally parse
|
||||
becomes a prefix handler. So creating a new word? Use the <span class="tt">:</span>
|
||||
prefix. Strings? Use <span class="tt">'</span>. Pointers? Try <span class="tt">&</span>. And so on. E.g.,
|
||||
becomes a sigil handler. So creating a new word? Use the <span class="tt">:</span>
|
||||
sigil. Strings? Use <span class="tt">'</span>. Pointers? Try <span class="tt">&</span>. And so on. E.g.,
|
||||
<br/><br/>
|
||||
<tt class='indentedcode'>In ANS | In RETRO</tt>
|
||||
<tt class='indentedcode'>: foo ... ; | :foo ... ;</tt>
|
||||
|
@ -82,12 +82,12 @@ prefix. Strings? Use <span class="tt">'</span>. Pointers? Try <span class="tt">&
|
|||
<tt class='indentedcode'>: bar ... ['] foo ; | :bar ... &foo ;</tt>
|
||||
<tt class='indentedcode'>s" hello world!" | 'hello_world!</tt>
|
||||
<br/><br/>
|
||||
If you are familiar with ColorForth, prefixes are a similar
|
||||
If you are familiar with ColorForth, sigils are a similar
|
||||
idea to colors, but can be defined by the user as normal words.
|
||||
<br/><br/>
|
||||
After doing this for quite a while I rather like it. I can see
|
||||
why Chuck Moore eventually went towards ColorForth as using
|
||||
color (or prefixes in my case) does simplify the implementation
|
||||
color (or sigils in my case) does simplify the implementation
|
||||
in many ways.
|
||||
</p>
|
||||
</body></html>
|
||||
|
|
|
@ -58,9 +58,9 @@ Consider:
|
|||
<tt class='indentedcode'>'test_name var</tt>
|
||||
<tt class='indentedcode'>#188 !test_name</tt>
|
||||
<br/><br/>
|
||||
In the first case, the <span class="tt">:</span> prefix handles the token, so the
|
||||
In the first case, the <span class="tt">:</span> sigil handles the token, so the
|
||||
underscore is not remapped to a space, creating a word name as
|
||||
<span class="tt">hello_msg</span>. But in the second, the <span class="tt">'</span> prefix remaps the
|
||||
<span class="tt">hello_msg</span>. But in the second, the <span class="tt">'</span> sigil remaps the
|
||||
underscore to a space, giving a variable name of <span class="tt">test name</span>.
|
||||
In the third line, the name lookup will fail as <span class="tt">test_name</span> is
|
||||
not defined, so the store will be done to an incorrect address.
|
||||
|
|
|
@ -145,7 +145,7 @@ Instead of:
|
|||
<br/><br/>
|
||||
<tt class='indentedcode'>i dudumu..</tt>
|
||||
<br/><br/>
|
||||
The runtime assembler also provides three prefixes for use in
|
||||
The runtime assembler also provides three sigils for use in
|
||||
inlining machine code into a definition. These are:
|
||||
<br/><br/>
|
||||
<tt class='indentedcode'> \ Treat token as an assembly sequence</tt>
|
||||
|
|
|
@ -47,9 +47,9 @@
|
|||
<br/><br/>
|
||||
RETRO provides words for working with ASCII characters.
|
||||
<br/><br/>
|
||||
<span class="h2">Prefix</span>
|
||||
<span class="h2">Sigil</span>
|
||||
<br/><br/>
|
||||
Character constants are returned using the <span class="tt">$</span> prefix.
|
||||
Character constants are returned using the <span class="tt">$</span> sigil.
|
||||
<br/><br/>
|
||||
<span class="h2">Namespace</span>
|
||||
<br/><br/>
|
||||
|
|
|
@ -54,7 +54,7 @@ precision (1 bit for the sign, 11 bits for the exponent, and
|
|||
the remaining 52 bits for the value), i.e. 15 decimal digits
|
||||
of precision.
|
||||
<br/><br/>
|
||||
<span class="h2">Prefix</span>
|
||||
<span class="h2">Sigil</span>
|
||||
<br/><br/>
|
||||
Floating point numbers start with a <span class="tt">.</span>
|
||||
<br/><br/>
|
||||
|
|
|
@ -51,7 +51,7 @@ Word names in RETRO generally follow the following conventions.
|
|||
<br/><br/>
|
||||
• Readability is important<br/>
|
||||
• Be consistent<br/>
|
||||
• Don't use a prefix as the first character of a name<br/>
|
||||
• Don't use a sigil as the first character of a name<br/>
|
||||
• Don't use underscores in word names<br/>
|
||||
• Use short names for indices<br/>
|
||||
• Word names start with a <span class="tt">-</span> for "not"<br/>
|
||||
|
@ -106,7 +106,7 @@ The common namespaces are:
|
|||
<tt class='indentedcode'>| err: | Words for handling errors |</tt>
|
||||
<tt class='indentedcode'>| io: | General I/O words |</tt>
|
||||
<tt class='indentedcode'>| n: | Words operating on numeric data |</tt>
|
||||
<tt class='indentedcode'>| prefix: | Contains prefix handlers |</tt>
|
||||
<tt class='indentedcode'>| sigil: | Contains sigil handlers |</tt>
|
||||
<tt class='indentedcode'>| s: | Words operating on string data |</tt>
|
||||
<tt class='indentedcode'>| v: | Words operating on variables |</tt>
|
||||
<tt class='indentedcode'>| file: | File I/O words |</tt>
|
||||
|
@ -115,15 +115,15 @@ The common namespaces are:
|
|||
<br/><br/>
|
||||
<span class="h2">Tips</span>
|
||||
<br/><br/>
|
||||
<span class="h3">Don't Start Names With Prefix Characters</span>
|
||||
<span class="h3">Don't Start Names With Sigil Characters</span>
|
||||
<br/><br/>
|
||||
Avoid using a prefix as the first character of a word name. RETRO
|
||||
will look for prefixes first, this will prevent direct use of
|
||||
Avoid using a sigil as the first character of a word name. RETRO
|
||||
will look for sigils first, this will prevent direct use of
|
||||
the work in question.
|
||||
<br/><br/>
|
||||
To find a list of prefix characters, do:
|
||||
To find a list of sigil characters, do:
|
||||
<br/><br/>
|
||||
<tt class='indentedcode'>'prefix: d:words-with</tt>
|
||||
<tt class='indentedcode'>'sigil: d:words-with</tt>
|
||||
<br/><br/>
|
||||
<span class="h3">Don't Use Underscores</span>
|
||||
<br/><br/>
|
||||
|
|
|
@ -47,9 +47,9 @@
|
|||
<br/><br/>
|
||||
Numbers in RETRO are signed integers.
|
||||
<br/><br/>
|
||||
<span class="h2">Token Prefix</span>
|
||||
<span class="h2">Sigil</span>
|
||||
<br/><br/>
|
||||
All numbers start with a <span class="tt">#</span> prefix.
|
||||
All numbers start with a <span class="tt">#</span> sigil.
|
||||
<br/><br/>
|
||||
<span class="h2">Namespace</span>
|
||||
<br/><br/>
|
||||
|
|
|
@ -45,9 +45,9 @@
|
|||
</head><body>
|
||||
<p><span class="h1">Working With Pointers</span>
|
||||
<br/><br/>
|
||||
<span class="h2">Prefix</span>
|
||||
<span class="h2">Sigil</span>
|
||||
<br/><br/>
|
||||
Pointers are returned by the <span class="tt">&</span> prefix.
|
||||
Pointers are returned by the <span class="tt">&</span> sigil.
|
||||
<br/><br/>
|
||||
<span class="h2">Examples</span>
|
||||
<br/><br/>
|
||||
|
|
|
@ -54,7 +54,7 @@ strings can contain UTF8 encoded data if the host platform
|
|||
allows. Words like <span class="tt">s:length</span> will return the number of bytes,
|
||||
not the number of logical characters in this case.
|
||||
<br/><br/>
|
||||
<span class="h2">Prefix</span>
|
||||
<span class="h2">Sigil</span>
|
||||
<br/><br/>
|
||||
Strings begin with a single <span class="tt">'</span>.
|
||||
<br/><br/>
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,7 +1,7 @@
|
|||
$ -c - - Return ASCII:NUL (0). class:macro {n/a} {n/a} global all
|
||||
' -s - - Return an empty string. class:macro {n/a} {n/a} global all
|
||||
( - - - Provide a visual indication of a code group. class:macro {n/a} {n/a} prefix all
|
||||
) - - - Provide a visual indication of a code group. class:macro {n/a} {n/a} prefix all
|
||||
( - - - Provide a visual indication of a code group. class:macro {n/a} {n/a} sigil all
|
||||
) - - - Provide a visual indication of a code group. class:macro {n/a} {n/a} sigil all
|
||||
* nn-n - - Multiply `n1` by `n2` and return the result. class:primitive #2 #6 *\n #-1 #100 * {n/a} global all
|
||||
+ nn-n - - Add `n1` to `n2` and return the result. class:primitive #1 #2 + {n/a} global all
|
||||
, n- - - Store the specified value into the memory at `here` and increment `Heap` by 1. class:word $a , $b , $c , #0 , {n/a} global all
|
||||
|
@ -358,19 +358,6 @@ pb:get a- - - Copy a string from the pasteboard to the specified address. clas
|
|||
pb:length -n - - Return the length of the string on the pasteboard. class:word {n/a} pb pb iOS
|
||||
pb:set s- - - Copy a string to the pasteboard. class:word {n/a} {n/a} pb iOS
|
||||
pop -n n- - Move a value from the return stack to the data stack. class:macro {n/a} {n/a} global all
|
||||
prefix:! ns- - - Store a value into a variable. Store a value into the named variable. Compile the code to store a value into a named variable. class:macro {n/a} {n/a} prefix all
|
||||
prefix:# s-n - - Process token as a number. Convert the string into a number and leave on the stack. Convert the string into a number and compile into the current definition as a literal. class:macro {n/a} {n/a} prefix all
|
||||
prefix:$ s-c - - Process token as an ASCII character. Fetch first character from string. Leave on stack. Fetch first character from the string. Compile into the current definition as literal. class:macro {n/a} {n/a} prefix all
|
||||
prefix:& s-a - - Return a pointer to a named item. Lookup name in dictionary, return contents of the xt field on the stack. Lookup name in dictionary, compile code to push the contents of the xt field into the current definition. class:macro {n/a} {n/a} prefix all
|
||||
prefix:' s-s - - Process token as a string. Move string into temporary buffer. If `RewriteUnderscores` is `TRUE`, replace all instances of _ with space. Move string into temporary buffer. If `RewriteUnderscores` is `TRUE`, replace all instances of _ with space. Then compile the string into the current definition. class:macro {n/a} {n/a} prefix all
|
||||
prefix:( s- - - Process token as a comment. Discard the string. Discard the string. class:macro {n/a} {n/a} prefix all
|
||||
prefix:. s- - -F Interpret time: convert string to a floating point value. Compile time: convert string to a floating point value and compile code to push this value to the float stack. class:macro {n/a} {n/a} prefix rre
|
||||
prefix:: s- - - Process token as a new definition. Create a header pointing to `here` with the provided string as the name. Sets class to `class:word`. class:macro {n/a} {n/a} prefix all
|
||||
prefix:@ s-n - - Fetch from a stored variable. Fetch a value from a named variable. Compile the code to fetch a value from a named variable into the current definition. class:macro {n/a} {n/a} prefix all
|
||||
prefix:\ s- - - Process token as an instruction bundle. Discard the string. Assemble the opcodes in the string and use `,` to inline it into the current definition. class:macro {n/a} {n/a} prefix all
|
||||
prefix:^ s- - - Process token as a function reference. Discard the string. Comma the XT of the word into the current definition. class:macro {n/a} {n/a} prefix all
|
||||
prefix:` s- - - Process token as a bytecode. Discard the string. Convert the string to a number and use `,` to inline it into the current definition. class:macro {n/a} {n/a} prefix all
|
||||
prefix:| s- - - POSTPONE equivalent. Discard the string. Convert the string to a number and use `,` to inline it into the current definition. class:macro {n/a} {n/a} prefix all
|
||||
primitive - - - Change the class of the most recently defined word to `class:primitive`. class:word {n/a} {n/a} global all
|
||||
push n- -n - Move a value from the data stack to the return stack. class:macro {n/a} {n/a} global all
|
||||
r s- - - Lookup a reference by name and inline its pointer to the current assembly segment. class:word {n/a} {n/a} global all
|
||||
|
@ -440,6 +427,19 @@ script:ignore-to-eol - - - Discard remaining tokens in the current line. This on
|
|||
script:name -s - - Return the filename of the program being run. class:word {n/a} {n/a} sys rre
|
||||
set-hook aa- - - Patch the hook point in a2 to point to a1. class:word :foo hook ;\n :bar #1 ;\n &bar &foo set-hook {n/a} global all
|
||||
shift mn-o - - Peform a bitwise shift of m by n bits. If n is positive, shift right. If negative, the shift will be to the left. class:primitive {n/a} {n/a} global all
|
||||
sigil:! ns- - - Store a value into a variable. Store a value into the named variable. Compile the code to store a value into a named variable. class:macro {n/a} {n/a} sigil all
|
||||
sigil:# s-n - - Process token as a number. Convert the string into a number and leave on the stack. Convert the string into a number and compile into the current definition as a literal. class:macro {n/a} {n/a} sigil all
|
||||
sigil:$ s-c - - Process token as an ASCII character. Fetch first character from string. Leave on stack. Fetch first character from the string. Compile into the current definition as literal. class:macro {n/a} {n/a} sigil all
|
||||
sigil:& s-a - - Return a pointer to a named item. Lookup name in dictionary, return contents of the xt field on the stack. Lookup name in dictionary, compile code to push the contents of the xt field into the current definition. class:macro {n/a} {n/a} sigil all
|
||||
sigil:' s-s - - Process token as a string. Move string into temporary buffer. If `RewriteUnderscores` is `TRUE`, replace all instances of _ with space. Move string into temporary buffer. If `RewriteUnderscores` is `TRUE`, replace all instances of _ with space. Then compile the string into the current definition. class:macro {n/a} {n/a} sigil all
|
||||
sigil:( s- - - Process token as a comment. Discard the string. Discard the string. class:macro {n/a} {n/a} sigil all
|
||||
sigil:. s- - -F Interpret time: convert string to a floating point value. Compile time: convert string to a floating point value and compile code to push this value to the float stack. class:macro {n/a} {n/a} sigil rre
|
||||
sigil:: s- - - Process token as a new definition. Create a header pointing to `here` with the provided string as the name. Sets class to `class:word`. class:macro {n/a} {n/a} sigil all
|
||||
sigil:@ s-n - - Fetch from a stored variable. Fetch a value from a named variable. Compile the code to fetch a value from a named variable into the current definition. class:macro {n/a} {n/a} sigil all
|
||||
sigil:\ s- - - Process token as an instruction bundle. Discard the string. Assemble the opcodes in the string and use `,` to inline it into the current definition. class:macro {n/a} {n/a} sigil all
|
||||
sigil:^ s- - - Process token as a function reference. Discard the string. Comma the XT of the word into the current definition. class:macro {n/a} {n/a} sigil all
|
||||
sigil:` s- - - Process token as a bytecode. Discard the string. Convert the string to a number and use `,` to inline it into the current definition. class:macro {n/a} {n/a} sigil all
|
||||
sigil:| s- - - POSTPONE equivalent. Discard the string. Convert the string to a number and use `,` to inline it into the current definition. class:macro {n/a} {n/a} sigil all
|
||||
sip nq-n - - Run quote. After execution completes, put a copy of n back on top of the stack. class:word {n/a} {n/a} global all
|
||||
socket:accept n-nn - - Begin accepting connections. Returns a new socket and an error code. class:word {n/a} {n/a} socket rre
|
||||
socket:bind sn-nn - - Bind a socket to a port. The port should be a string. Returns 0 if successful or -1 otherwise and an error code. class:word {n/a} {n/a} socket rre
|
||||
|
|
Can't render this file because it contains an unexpected character in line 14 and column 96.
|
|
@ -10,7 +10,7 @@ This is a little experiment in combinator-driven HTML generation.
|
|||
:h1 (s-) '<h1> s:put s:put '</h1> s:put nl ;
|
||||
:div (q-) '<div> s:put call '</div> s:put nl ;
|
||||
:body (q-) '<body> s:put call '</body> s:put nl ;
|
||||
:prefix:" s:keep &s:put compile:call ; immediate
|
||||
:sigil:" s:keep &s:put compile:call ; immediate
|
||||
~~~
|
||||
|
||||
Test case:
|
||||
|
|
|
@ -78,10 +78,10 @@ far.
|
|||
|
||||
~~~
|
||||
{{
|
||||
:prefix?
|
||||
TIB fetch 'prefix:_ [ #7 + store ] sip d:lookup n:-zero? ;
|
||||
:sigil?
|
||||
TIB fetch 'sigil:_ [ #7 + store ] sip d:lookup n:-zero? ;
|
||||
:hint
|
||||
nl TIB prefix? [ n:inc ] if d:words-beginning-with nl
|
||||
nl TIB sigil? [ n:inc ] if d:words-beginning-with nl
|
||||
TIB s:put ;
|
||||
---reveal---
|
||||
:handle:tab (c-c) hook
|
||||
|
@ -91,7 +91,7 @@ far.
|
|||
|
||||
Control + k (`ASCII:VT`) will display help for the word being typed.
|
||||
This assumes that `retro-describe` is in your $PATH and that the
|
||||
typed text is a complete word name (without a prefix).
|
||||
typed text is a complete word name (without a sigil).
|
||||
|
||||
~~~
|
||||
:handle:CTRL+K (c-c) hook
|
||||
|
|
|
@ -15,7 +15,7 @@ Determine the average length of a word name.
|
|||
/ 'Average_name_length:_%n\n s:format s:put
|
||||
~~~
|
||||
|
||||
And without the prefixes...
|
||||
And without the namespaces...
|
||||
|
||||
~~~
|
||||
#0 #0 [ d:name dup $: s:index-of n:inc + s:length + [ n:inc ] dip ] d:for-each swap /
|
||||
|
|
|
@ -202,7 +202,7 @@ delimiters.
|
|||
~~~
|
||||
|
||||
On to generating the actual HTML for the syntax highlighted
|
||||
source. This is driven by the prefix, then by word class via
|
||||
source. This is driven by the sigil, then by word class via
|
||||
a little quick introspection.
|
||||
|
||||
~~~
|
||||
|
@ -213,8 +213,8 @@ a little quick introspection.
|
|||
:format-code (s-)
|
||||
(ignore_empty_tokens)
|
||||
dup s:length n:zero? [ ' s:put drop ] if;
|
||||
|
||||
(tokens_with_prefixes)
|
||||
|
||||
(tokens_with_sigils)
|
||||
dup fetch
|
||||
$: [ 'colon span ] case
|
||||
$( [ 'note span ] case
|
||||
|
|
|
@ -66,7 +66,7 @@ Everything else gets treated as text.
|
|||
(ignore_empty_tokens)
|
||||
dup s:length n:zero? [ drop ] if;
|
||||
|
||||
(tokens_with_prefixes)
|
||||
(tokens_with_sigils)
|
||||
dup fetch
|
||||
$: [ 'name span ] case
|
||||
$s [ 'string span ] case
|
||||
|
|
|
@ -219,7 +219,7 @@ delimiters.
|
|||
~~~
|
||||
|
||||
On to generating the actual HTML for the syntax highlighted
|
||||
source. This is driven by the prefix, then by word class via
|
||||
source. This is driven by the sigil, then by word class via
|
||||
a little quick introspection.
|
||||
|
||||
~~~
|
||||
|
@ -230,8 +230,8 @@ a little quick introspection.
|
|||
:format-code (s-)
|
||||
(ignore_empty_tokens)
|
||||
dup s:length n:zero? [ ' s:put drop ] if;
|
||||
|
||||
(tokens_with_prefixes)
|
||||
|
||||
(tokens_with_sigils)
|
||||
dup fetch
|
||||
$: [ 'colon span ] case
|
||||
$( [ 'note span ] case
|
||||
|
|
|
@ -65,7 +65,7 @@ be useful if you are running on a VM with an extended instruction
|
|||
set.
|
||||
|
||||
When loaded, it will *replace* the original `i` with a jump to
|
||||
the one provided here, allowing existing words (like `prefix:\`)
|
||||
the one provided here, allowing existing words (like `sigil:\`)
|
||||
to use this instead.
|
||||
|
||||
----
|
||||
|
|
|
@ -9,7 +9,7 @@ like:
|
|||
|
||||
: foo ... ;
|
||||
|
||||
In Retro, there are no parsing words. There is a prefix
|
||||
In Retro, there are no parsing words. There is a sigil
|
||||
handler `:`, yielding:
|
||||
|
||||
:foo ... ;
|
||||
|
|
|
@ -1,47 +1,47 @@
|
|||
Numbers without the # Prefix
|
||||
Numbers without the # Sigil
|
||||
|
||||
RETRO requires a # prefix to identify numbers. But since new
|
||||
prefixes can be defined, it's possible to define prefixes for
|
||||
RETRO requires a # sigil to identify numbers. But since new
|
||||
sigils can be defined, it's possible to define sigils for
|
||||
the number starting with 0-9.
|
||||
|
||||
This is actually easy (at least for positive numbers). Just
|
||||
define a prefix handler that prepends the initial value back
|
||||
on the string (since the string sans the prefix is passed to
|
||||
define a sigil handler that prepends the initial value back
|
||||
on the string (since the string sans the sigil is passed to
|
||||
the handler) and pass it to `s:to-number` and `class:data`.
|
||||
|
||||
~~~
|
||||
{{
|
||||
:process-with-prefix (s-n)
|
||||
:process-with-sigil (s-n)
|
||||
s:prepend s:to-number class:data ;
|
||||
---reveal---
|
||||
:prefix:1 (s-n) '1 process-with-prefix ; immediate
|
||||
:prefix:2 (s-n) '2 process-with-prefix ; immediate
|
||||
:prefix:3 (s-n) '3 process-with-prefix ; immediate
|
||||
:prefix:4 (s-n) '4 process-with-prefix ; immediate
|
||||
:prefix:5 (s-n) '5 process-with-prefix ; immediate
|
||||
:prefix:6 (s-n) '6 process-with-prefix ; immediate
|
||||
:prefix:7 (s-n) '7 process-with-prefix ; immediate
|
||||
:prefix:8 (s-n) '8 process-with-prefix ; immediate
|
||||
:prefix:9 (s-n) '9 process-with-prefix ; immediate
|
||||
:sigil:1 (s-n) '1 process-with-sigil ; immediate
|
||||
:sigil:2 (s-n) '2 process-with-sigil ; immediate
|
||||
:sigil:3 (s-n) '3 process-with-sigil ; immediate
|
||||
:sigil:4 (s-n) '4 process-with-sigil ; immediate
|
||||
:sigil:5 (s-n) '5 process-with-sigil ; immediate
|
||||
:sigil:6 (s-n) '6 process-with-sigil ; immediate
|
||||
:sigil:7 (s-n) '7 process-with-sigil ; immediate
|
||||
:sigil:8 (s-n) '8 process-with-sigil ; immediate
|
||||
:sigil:9 (s-n) '9 process-with-sigil ; immediate
|
||||
~~~
|
||||
|
||||
`0` is a special case. Since RETRO has `0;` as a control
|
||||
flow word, the `0` prefix would prevent using it. So the
|
||||
flow word, the `0` sigil would prevent using it. So the
|
||||
handler for this checks to see if the part following the
|
||||
prefix is a `;`. If so, it'll fall back to `0;`, otherwise
|
||||
sigil is a `;`. If so, it'll fall back to `0;`, otherwise
|
||||
it treats the token as a number.
|
||||
|
||||
~~~
|
||||
:prefix:0 (s-n)
|
||||
:sigil:0 (s-n)
|
||||
dup '; s:eq?
|
||||
[ drop &0; call ]
|
||||
[ '0 process-with-prefix ] choose ; immediate
|
||||
[ '0 process-with-sigil ] choose ; immediate
|
||||
}}
|
||||
~~~
|
||||
|
||||
For single digits, define each digit as a word. (Prefixes
|
||||
For single digits, define each digit as a word. (Sigils
|
||||
are not processed for tokens with nothing other than the
|
||||
prefix character, so this takes care of the issue).
|
||||
sigil character, so this takes care of the issue).
|
||||
|
||||
~~~
|
||||
:0 (-n) #0 ;
|
||||
|
@ -58,7 +58,7 @@ prefix character, so this takes care of the issue).
|
|||
|
||||
Handling negative numbers is a bigger headache though. By
|
||||
convention, RETRO uses - to imply "not" (as in `-eq?`). So
|
||||
to handle the `-` prefix for numbers, it needs to fall back
|
||||
to handle the `-` sigil for numbers, it needs to fall back
|
||||
to a dictionary search if the token isn't actually a number.
|
||||
|
||||
~~~
|
||||
|
@ -72,7 +72,7 @@ to a dictionary search if the token isn't actually a number.
|
|||
:call-with-class (d-)
|
||||
[ d:xt fetch ] [ d:class fetch ] bi call ;
|
||||
---reveal---
|
||||
:prefix:- (s-)
|
||||
:sigil:- (s-)
|
||||
numeric?
|
||||
[ s:to-number n:negate class:data ]
|
||||
[ in-dictionary? &report-error &call-with-class choose ] choose ; immediate
|
||||
|
|
|
@ -56,7 +56,7 @@ quick implementation. (The actual preseve/restore using the
|
|||
> this later.
|
||||
|
||||
I'm not comfortable with this as it does add some overhead. The colon
|
||||
prefix is extended to add a jump around word entries, so that nesting
|
||||
sigil is extended to add a jump around word entries, so that nesting
|
||||
can work properly. This also extends the colon and semicolon words to
|
||||
add support for preserving the `my` and `at` variables.
|
||||
|
||||
|
@ -74,7 +74,7 @@ add support for preserving the `my` and `at` variables.
|
|||
!Compiler here swap store
|
||||
&Nest v:dec @Nest n:zero? [ @Scope !Dictionary ] if ; immediate
|
||||
---reveal---
|
||||
:prefix:: def ; immediate
|
||||
:sigil:: def ; immediate
|
||||
:; |-def -def immediate
|
||||
#0 !Nest
|
||||
}}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
This is a quick little thing to generate some statistics
|
||||
from the RETRO image and VM, along with some introspection
|
||||
to identify prefix handlers and word classes.
|
||||
to identify sigil handlers and word classes.
|
||||
|
||||
# Memory Use
|
||||
|
||||
|
@ -56,7 +56,7 @@ Determine the average length of a word name.
|
|||
/ '__Average_name_length:_%n\n s:format s:put
|
||||
~~~
|
||||
|
||||
And without the prefixes...
|
||||
And without the sigils...
|
||||
|
||||
~~~
|
||||
#0 #0 [ d:name dup $: s:index-of n:inc + s:length + [ n:inc ] dip ] d:for-each swap /
|
||||
|
@ -92,11 +92,11 @@ nl 'Classes: s:put nl nl
|
|||
sp sp identify-classes [ s:put sp ] a:for-each nl
|
||||
~~~
|
||||
|
||||
# Identify Prefixes
|
||||
# Identify Sigils
|
||||
|
||||
Prefixes are named as:
|
||||
Sigils are named as:
|
||||
|
||||
prefix:<character>
|
||||
sigil:<character>
|
||||
|
||||
Unlike classes, this is not merely a convention, but an actual
|
||||
requirement.
|
||||
|
@ -105,15 +105,15 @@ The process for obtaining an array of them and printing it is
|
|||
the same as with the class handlers.
|
||||
|
||||
~~~
|
||||
nl 'Prefixes: s:put nl nl
|
||||
nl 'Sigils: s:put nl nl
|
||||
|
||||
:identify-prefixes (-a)
|
||||
:identify-sigils (-a)
|
||||
here #0 ,
|
||||
[ d:name dup 'prefix: s:contains-string?
|
||||
[ d:name dup 'sigil: s:contains-string?
|
||||
&, &drop choose ] d:for-each
|
||||
here over - n:dec over store ;
|
||||
|
||||
sp sp identify-prefixes [ s:put sp ] a:for-each nl
|
||||
sp sp identify-sigils [ s:put sp ] a:for-each nl
|
||||
|
||||
nl
|
||||
~~~
|
||||
|
|
|
@ -2,7 +2,7 @@ This implements a sort of "safety net", adding some compile and runtime
|
|||
error checking and reporting.
|
||||
|
||||
|
||||
The first of these is to extend the `@` and `!` prefixes to check for
|
||||
The first of these is to extend the `@` and `!` sigils to check for
|
||||
the existence of a word name. In a basic image, if the name isn't found,
|
||||
it will resolve to address 0 silently. This will have it report an error
|
||||
if the word is not found.
|
||||
|
@ -14,11 +14,11 @@ if the word is not found.
|
|||
:if:not-defined (sq-s)
|
||||
over d:lookup n:zero? swap if ;
|
||||
|
||||
:prefix:@
|
||||
:sigil:@
|
||||
[ err:var-not-defined ] if:not-defined
|
||||
d:lookup d:xt fetch class:data |fetch ; immediate
|
||||
|
||||
:prefix:!
|
||||
:sigil:!
|
||||
[ err:var-not-defined ] if:not-defined
|
||||
d:lookup d:xt fetch class:data |store ; immediate
|
||||
~~~
|
||||
|
|
|
@ -47,7 +47,7 @@ the global dictionary with the sandboxed one.
|
|||
# A Test Case
|
||||
|
||||
This will expose a dictionary with just two words that can be
|
||||
used with a new `%` prefix.
|
||||
used with a new `%` sigil.
|
||||
|
||||
```
|
||||
{{
|
||||
|
@ -55,7 +55,7 @@ used with a new `%` prefix.
|
|||
:dup $B ;
|
||||
dict{ 'swap 'dup }dict 'SANDBOX const
|
||||
---reveal---
|
||||
:prefix:% (s) [ s:evaluate c:put ] SANDBOX d:with ;
|
||||
:sigil:% (s) [ s:evaluate c:put ] SANDBOX d:with ;
|
||||
}}
|
||||
|
||||
#70 dup swap
|
||||
|
|
|
@ -47,19 +47,19 @@ across namespaces. E.g.,
|
|||
s:put
|
||||
s:to-upper
|
||||
|
||||
### Prefixes
|
||||
### Sigils
|
||||
|
||||
Prefixes are an integral part of RETRO. These are single symbol
|
||||
Sigils are an integral part of RETRO. These are single symbol
|
||||
modifiers added to the start of a word which control how RETRO
|
||||
processes the word.
|
||||
|
||||
The interpreter model is covered in *Rx.md*, but basically:
|
||||
The interpreter model is covered in *retro.muri*, but basically:
|
||||
|
||||
- Get a token (whitespace delimited string)
|
||||
- Pass it to `interpret`
|
||||
+ if the token starts with a known prefix then pass
|
||||
it to the prefix handler
|
||||
+ if the initial character is not a known prefix,
|
||||
+ if the token starts with a known sigil then pass
|
||||
it to the sigil handler
|
||||
+ if the initial character is not a known sigil,
|
||||
look it up
|
||||
- if found, push the address ("xt") to the stack
|
||||
and call the word's class handler
|
||||
|
@ -70,12 +70,12 @@ This is different than the process in traditional Forth. A few
|
|||
observations:
|
||||
|
||||
- there are no parsing words
|
||||
- numbers are handled using a prefix
|
||||
- prefixes can be added or changed at any time
|
||||
- numbers are handled using a sigil
|
||||
- sigils can be added or changed at any time
|
||||
|
||||
The basic prefixes are:
|
||||
The basic sigils are:
|
||||
|
||||
| prefix | used for |
|
||||
| sigil | used for |
|
||||
| ------ | ---------------------- |
|
||||
| : | starting a definition |
|
||||
| & | obtaining pointers |
|
||||
|
@ -96,7 +96,7 @@ The basic prefixes are:
|
|||
* Word names should be lowercase
|
||||
* Variable names should be Title case
|
||||
* Constants should be UPPERCASE
|
||||
* Names may not start with a prefix character
|
||||
* Names may not start with a sigil character
|
||||
* Names returning a flag should end with a ?
|
||||
* Words with an effect on the stack should have a stack comment
|
||||
|
||||
|
@ -227,12 +227,12 @@ have an accessor word that aids in readability.
|
|||
~~~
|
||||
|
||||
It's sometimes useful to inline values directly. I use a
|
||||
backtick prefix for this.
|
||||
backtick sigil for this.
|
||||
|
||||
~~~
|
||||
:prefix:` (s-) s:to-number , ; immediate
|
||||
:prefix:\ (s-) i ; immediate
|
||||
:prefix:^ (s-) r ; immediate
|
||||
:sigil:` (s-) s:to-number , ; immediate
|
||||
:sigil:\ (s-) i ; immediate
|
||||
:sigil:^ (s-) r ; immediate
|
||||
~~~
|
||||
|
||||
It's traditional to have a word named `here` which returns the
|
||||
|
@ -244,9 +244,9 @@ next free address in memory.
|
|||
|
||||
## Variables
|
||||
|
||||
The next two are additional prefixes to make working with
|
||||
variables a bit less painful. By default you have to do things
|
||||
like:
|
||||
The next two are additional sigils to make working with
|
||||
variables a bit less painful. By default you have to do
|
||||
things like:
|
||||
|
||||
&Name fetch #10 * &Name store
|
||||
|
||||
|
@ -254,7 +254,7 @@ Or using combinators:
|
|||
|
||||
&Name [ fetch #10 * ] sip store
|
||||
|
||||
With the @ and ! prefixes this can become:
|
||||
With the @ and ! sigils this can become:
|
||||
|
||||
@Name #10 * !Name
|
||||
|
||||
|
@ -265,19 +265,19 @@ corresponding to:
|
|||
lit + store + nop + nop 'list.... #4097
|
||||
|
||||
~~~
|
||||
:prefix:@ (s-n)
|
||||
:sigil:@ (s-n)
|
||||
d:lookup d:xt fetch
|
||||
compiling? [ (life.... #3841 , , ) ]
|
||||
[ fetch ] choose ; immediate
|
||||
|
||||
:prefix:! (s-n)
|
||||
:sigil:! (s-n)
|
||||
d:lookup d:xt fetch
|
||||
compiling? [ (list.... #4097 , , ) ]
|
||||
[ store ] choose ; immediate
|
||||
~~~
|
||||
|
||||
The next few words aren't actually useful until the `s:`
|
||||
namespace is defined. With strings and the `'` prefix they
|
||||
namespace is defined. With strings and the `'` sigil they
|
||||
allow creation of variables and constants.
|
||||
|
||||
| To create a | Use a form like |
|
||||
|
@ -451,7 +451,7 @@ to:
|
|||
## A Shortcut
|
||||
|
||||
~~~
|
||||
:prefix:|
|
||||
:sigil:|
|
||||
d:lookup [ d:xt fetch ] [ d:class fetch ] bi
|
||||
compiling? [ &class:data dip compile:call ]
|
||||
&call choose ; immediate
|
||||
|
@ -784,7 +784,7 @@ pointer to skip to the code following the stored string.
|
|||
here &s, dip class:data ;
|
||||
~~~
|
||||
|
||||
And now a quick `'` prefix. (This will be replaced later). What
|
||||
And now a quick `'` sigil. (This will be replaced later). What
|
||||
this does is either move the string token to the temporary
|
||||
buffer or compile it into the current definition.
|
||||
|
||||
|
@ -796,7 +796,7 @@ Later in the code I'll add a better implementation which can
|
|||
handle conversion of _ into spaces.
|
||||
|
||||
~~~
|
||||
:prefix:' compiling? &s:keep &s:temp choose ; immediate
|
||||
:sigil:' compiling? &s:keep &s:temp choose ; immediate
|
||||
~~~
|
||||
|
||||
`s:chop` removes the last character from a string.
|
||||
|
@ -1016,7 +1016,7 @@ characters that are of some general interest.
|
|||
~~~
|
||||
|
||||
I have a few words that correspond to empty versions of the
|
||||
prefixes.
|
||||
sigils.
|
||||
|
||||
~~~
|
||||
:' |s:empty ; immediate
|
||||
|
@ -1025,7 +1025,7 @@ prefixes.
|
|||
|
||||
## ASCII Constants
|
||||
|
||||
Not all characters can be obtained via the $ prefix. ASCII has
|
||||
Not all characters can be obtained via the $ sigil. ASCII has
|
||||
many characters that aren't really intended to be printable.
|
||||
RETRO has an `ASCII` namespace providing symbolic names for
|
||||
these.
|
||||
|
@ -1131,7 +1131,7 @@ Convert a decimal (base 10) number to a string.
|
|||
}}
|
||||
~~~
|
||||
|
||||
Now replace the old prefix:' with this one that can optionally
|
||||
Now replace the old sigil:' with this one that can optionally
|
||||
turn underscores into spaces.
|
||||
|
||||
~~~
|
||||
|
@ -1140,9 +1140,9 @@ TRUE 'RewriteUnderscores var-n
|
|||
{{
|
||||
:sub (c-c) $_ [ ASCII:SPACE ] case ;
|
||||
:rewrite (s-s) @RewriteUnderscores [ &sub s:map ] if ;
|
||||
:handle &prefix:' call ;
|
||||
:handle &sigil:' call ;
|
||||
---reveal---
|
||||
:prefix:' rewrite handle ; immediate
|
||||
:sigil:' rewrite handle ; immediate
|
||||
}}
|
||||
~~~
|
||||
|
||||
|
@ -1648,7 +1648,7 @@ remaining string.
|
|||
And then the `process-tokens` uses `next-token` and `interpret`
|
||||
to go through the string, processing each token in turn. Using
|
||||
the standard `interpret` word allows for proper handling of the
|
||||
prefixes and classes so everything works just as if entered
|
||||
sigils and classes so everything works just as if entered
|
||||
directly.
|
||||
|
||||
~~~
|
||||
|
|
156
image/retro.muri
156
image/retro.muri
|
@ -722,7 +722,7 @@ handler, and a pointer to the start of the function. RETRO does
|
|||
the rest.
|
||||
|
||||
In actual practice, I never use this outside of RETRO. New words
|
||||
are made using the `:` prefix, or `d:create` (once defined in
|
||||
are made using the `:` sigil, or `d:create` (once defined in
|
||||
the standard library). At some point I may simplify this by
|
||||
moving `d:create` into Rx and using it in place of `d:add-header`.
|
||||
|
||||
|
@ -849,94 +849,94 @@ i drmure..
|
|||
|
||||
An input token has a form like:
|
||||
|
||||
<prefix-char>string
|
||||
<sigil>string
|
||||
|
||||
RETRO will check the first character to see if it matches a
|
||||
known prefix. If it does, it will pass the string (sans prefix)
|
||||
to the prefix handler. If not, it will attempt to find the token
|
||||
known sigil. If it does, it will pass the string (sans sigil)
|
||||
to the sigil handler. If not, it will attempt to find the token
|
||||
in the dictionary.
|
||||
|
||||
Prefixes are handled by functions with specific naming
|
||||
conventions. A prefix name should be:
|
||||
Sigils are handled by functions with specific naming
|
||||
conventions. A sigil name should be:
|
||||
|
||||
prefix:<prefix-char>
|
||||
sigil:<sigil>
|
||||
|
||||
Where <prefix-char> is the character for the prefix. These are
|
||||
Where <sigil> is the character for the sigil. These are
|
||||
compiler macros (using the `class:macro` class) and watch the
|
||||
`Compiler` to decide how to deal with the token. To find a
|
||||
prefix, RETRO stores the prefix character into a string named
|
||||
`prefixed`. It then searches for this string in the dictionary.
|
||||
If found, it sets an internal variable (`prefix:handler`) to
|
||||
sigil, RETRO stores the sigil character into a string named
|
||||
`sigil`. It then searches for this string in the dictionary.
|
||||
If found, it sets an internal variable (`sigil:handler`) to
|
||||
the dictionary entry for the handler function. If not found,
|
||||
`prefix:handler` is set to zero. The check, done by `prefix?`,
|
||||
`sigil:handler` is set to zero. The check, done by `sigil?`,
|
||||
also returns a flag.
|
||||
|
||||
'_ 'prefix:no s:const
|
||||
'prefix:_ 'prefixed s:const
|
||||
'_ 'sigil:no s:const
|
||||
'sigil:_ 'sigil s:const
|
||||
|
||||
'prefix:handler var
|
||||
'sigil:handler var
|
||||
|
||||
~~~
|
||||
: prefix:no
|
||||
: sigil:no
|
||||
d 32
|
||||
d 0
|
||||
|
||||
: prefix:handler
|
||||
: sigil:handler
|
||||
d 0
|
||||
|
||||
: prefixed
|
||||
s prefix:_
|
||||
: sigil
|
||||
s sigil:_
|
||||
~~~
|
||||
|
||||
:prefix:prepare
|
||||
fetch &prefixed #7 + store ;
|
||||
:sigil:prepare
|
||||
fetch &sigil #6 + store ;
|
||||
|
||||
~~~
|
||||
: prefix:prepare
|
||||
: sigil:prepare
|
||||
i feliliad
|
||||
r prefixed
|
||||
d 7
|
||||
r sigil
|
||||
d 6
|
||||
i stre....
|
||||
~~~
|
||||
|
||||
:prefix:has-token?
|
||||
dup s:length #1 0; drop-pair &prefix:no ;
|
||||
:sigil:has-token?
|
||||
dup s:length #1 0; drop-pair &sigil:no ;
|
||||
|
||||
~~~
|
||||
: prefix:has-token?
|
||||
: sigil:has-token?
|
||||
i dulica..
|
||||
r s:length
|
||||
i lieqzr..
|
||||
d 1
|
||||
i drdrlire
|
||||
r prefix:no
|
||||
r sigil:no
|
||||
~~~
|
||||
|
||||
:prefix?
|
||||
prefix:has-token? prefix:prepare &prefixed d:lookup
|
||||
dup &prefix:handler store #0 -eq? ;
|
||||
:sigil?
|
||||
sigil:has-token? sigil:prepare &sigil d:lookup
|
||||
dup &sigil:handler store #0 -eq? ;
|
||||
|
||||
~~~
|
||||
: prefix?
|
||||
: sigil?
|
||||
i lica....
|
||||
r prefix:has-token?
|
||||
r sigil:has-token?
|
||||
i lica....
|
||||
r prefix:prepare
|
||||
r sigil:prepare
|
||||
i lilica..
|
||||
r prefixed
|
||||
r sigil
|
||||
r d:lookup
|
||||
i dulistli
|
||||
r prefix:handler
|
||||
r sigil:handler
|
||||
d 0
|
||||
i nere....
|
||||
~~~
|
||||
|
||||
RETRO makes extensive use of prefixes for implementing major
|
||||
parts of the language, including parsing numbers (prefix with
|
||||
`#`), obtaining pointers (prefix with `&`), and defining
|
||||
functions (using the `:` prefix).
|
||||
RETRO makes extensive use of sigils for implementing major
|
||||
parts of the language, including parsing numbers (`#` sigil),
|
||||
obtaining pointers (`&`), and defining functions (using the
|
||||
`:` sigil).
|
||||
|
||||
| prefix | used for | example |
|
||||
| sigil | used for | example |
|
||||
| ------ | ----------------- | ------- |
|
||||
| # | numbers | #100 |
|
||||
| $ | ASCII characters | $e |
|
||||
|
@ -944,38 +944,38 @@ functions (using the `:` prefix).
|
|||
| : | definitions | :foo |
|
||||
| ( | Comments | (n-) |
|
||||
|
||||
:prefix:( (s-) drop ;
|
||||
:sigil:( (s-) drop ;
|
||||
|
||||
~~~
|
||||
: prefix:(
|
||||
: sigil:(
|
||||
i drre....
|
||||
~~~
|
||||
|
||||
:prefix:# (s-n) s:to-number class:data ;
|
||||
:sigil:# (s-n) s:to-number class:data ;
|
||||
|
||||
~~~
|
||||
: prefix:#
|
||||
: sigil:#
|
||||
i lica....
|
||||
r s:to-number
|
||||
i liju....
|
||||
r class:data
|
||||
~~~
|
||||
|
||||
:prefix:$ (s-c) fetch class:data ;
|
||||
:sigil:$ (s-c) fetch class:data ;
|
||||
|
||||
~~~
|
||||
: prefix:$
|
||||
: sigil:$
|
||||
i feliju..
|
||||
r class:data
|
||||
~~~
|
||||
|
||||
:prefix:: (s-)
|
||||
:sigil:: (s-)
|
||||
&class:word &Heap fetch d:add-header
|
||||
&Heap fetch &Dictionary d:xt store
|
||||
#-1 &Compiler store ;
|
||||
|
||||
~~~
|
||||
: prefix::
|
||||
: sigil::
|
||||
i lilifeli
|
||||
r class:word
|
||||
r Heap
|
||||
|
@ -993,11 +993,11 @@ d -1
|
|||
r Compiler
|
||||
~~~
|
||||
|
||||
The `&` prefix is used to return the address of a named item.
|
||||
The `&` sigil is used to return the address of a named item.
|
||||
This will correspond to the `d:xt` field of the word header.
|
||||
In higher level Retro this would be:
|
||||
|
||||
:prefix:& (s-a) d:lookup d:xt fetch class:data ;
|
||||
:sigil:& (s-a) d:lookup d:xt fetch class:data ;
|
||||
|
||||
As an example:
|
||||
|
||||
|
@ -1005,7 +1005,7 @@ As an example:
|
|||
&Heap fetch (fetch_from_`Heap`)
|
||||
|
||||
In the latter case, the use of `class:data` means that I
|
||||
don't *need* to use the `&` prefix, but I do this anyway as
|
||||
don't *need* to use the `&` sigil, but I do this anyway as
|
||||
I find it helps to provide a visual clue as to the intent of
|
||||
the code.
|
||||
|
||||
|
@ -1013,13 +1013,13 @@ This is also useful with combinators. If you are only using
|
|||
a single word, using `&word` instead of `[ word ]` will be
|
||||
smaller and faster.
|
||||
|
||||
For those familiar with traditional Forth, the `&` prefix
|
||||
For those familiar with traditional Forth, the `&` sigil
|
||||
replaces both `'` and `[']`.
|
||||
|
||||
:prefix:& d:lookup d:xt fetch class:data ;
|
||||
:sigil:& d:lookup d:xt fetch class:data ;
|
||||
|
||||
~~~
|
||||
: prefix:&
|
||||
: sigil:&
|
||||
i lica....
|
||||
r d:lookup
|
||||
i lica....
|
||||
|
@ -1136,9 +1136,9 @@ r comma:opcode
|
|||
The *interpreter* is what processes input. What it does is:
|
||||
|
||||
* Take a string
|
||||
* See if the first character has a prefix handler
|
||||
* See if the first character has a sigil handler
|
||||
|
||||
* Yes: pass the rest of the string to the prefix handler
|
||||
* Yes: pass the rest of the string to the sigil handler
|
||||
* No: lookup in the dictionary
|
||||
|
||||
* Found: pass xt of word to the class handler
|
||||
|
@ -1181,11 +1181,11 @@ i feju....
|
|||
: input:source
|
||||
d 0
|
||||
|
||||
: interpret:prefix
|
||||
: interpret:sigil
|
||||
i ........
|
||||
i ........
|
||||
i lifezr..
|
||||
r prefix:handler
|
||||
r sigil:handler
|
||||
i lifeliad
|
||||
r input:source
|
||||
d 1
|
||||
|
@ -1197,7 +1197,7 @@ i lifeliju
|
|||
r Which
|
||||
r call:dt
|
||||
|
||||
: interpret:noprefix
|
||||
: interpret:nosigil
|
||||
i lifelica
|
||||
r input:source
|
||||
r d:lookup
|
||||
|
@ -1214,11 +1214,11 @@ r _interpret
|
|||
: _interpret
|
||||
i dulistli
|
||||
r input:source
|
||||
r prefix?
|
||||
r sigil?
|
||||
i ca......
|
||||
i lililiju
|
||||
r interpret:prefix
|
||||
r interpret:noprefix
|
||||
r interpret:sigil
|
||||
r interpret:nosigil
|
||||
r choose
|
||||
~~~
|
||||
|
||||
|
@ -1603,9 +1603,9 @@ r class:word
|
|||
s -if
|
||||
: 0029
|
||||
r 0028
|
||||
r prefix:(
|
||||
r sigil:(
|
||||
r class:macro
|
||||
s prefix:(
|
||||
s sigil:(
|
||||
: 0030
|
||||
r 0029
|
||||
r Compiler
|
||||
|
@ -1688,24 +1688,24 @@ r class:word
|
|||
s d:add-header
|
||||
: 0046
|
||||
r 0045
|
||||
r prefix:#
|
||||
r sigil:#
|
||||
r class:macro
|
||||
s prefix:#
|
||||
s sigil:#
|
||||
: 0047
|
||||
r 0046
|
||||
r prefix::
|
||||
r sigil::
|
||||
r class:macro
|
||||
s prefix::
|
||||
s sigil::
|
||||
: 0048
|
||||
r 0047
|
||||
r prefix:&
|
||||
r sigil:&
|
||||
r class:macro
|
||||
s prefix:&
|
||||
s sigil:&
|
||||
: 0049
|
||||
r 0048
|
||||
r prefix:$
|
||||
r sigil:$
|
||||
r class:macro
|
||||
s prefix:$
|
||||
s sigil:$
|
||||
: 0050
|
||||
r 0049
|
||||
r repeat
|
||||
|
@ -1808,11 +1808,11 @@ s err:notfound
|
|||
| class:macro | p- | Class handler for immediate functions |
|
||||
| class:data | p- | Class handler for data |
|
||||
| d:add-header | saa- | Add an item to the dictionary |
|
||||
| prefix:# | s- | # prefix for numbers |
|
||||
| prefix:: | s- | : prefix for definitions |
|
||||
| prefix:& | s- | & prefix for pointers |
|
||||
| prefix:$ | s- | $ prefix for ASCII characters |
|
||||
| prefix:( | s- | ( prefix for comments |
|
||||
| sigil:# | s- | # sigil for numbers |
|
||||
| sigil:: | s- | : sigil for definitions |
|
||||
| sigil:& | s- | & sigil for pointers |
|
||||
| sigil:$ | s- | $ sigil for ASCII characters |
|
||||
| sigil:( | s- | ( sigil for comments |
|
||||
| repeat | -a | Start an unconditional loop |
|
||||
| again | a- | End an unconditional loop |
|
||||
| interpret | s-? | Evaluate a token |
|
||||
|
|
|
@ -59,10 +59,10 @@ to aid in structuring the floating point stack.
|
|||
~~~
|
||||
|
||||
Then a word to allow creation of floating point values via a
|
||||
`,` prefix.
|
||||
`,` sigil.
|
||||
|
||||
~~~
|
||||
:prefix:, (s-__dec:-a)
|
||||
:sigil:, (s-__dec:-a)
|
||||
compiling? &s:keep &s:temp choose &s:to-decimal class:word ; immediate
|
||||
~~~
|
||||
|
||||
|
|
|
@ -69,10 +69,10 @@ to aid in structuring the floating point stack.
|
|||
~~~
|
||||
|
||||
Then a word to allow creation of floating point values via a
|
||||
`.` prefix.
|
||||
`.` sigil.
|
||||
|
||||
~~~
|
||||
:prefix:. (s-__f:-a)
|
||||
:sigil:. (s-__f:-a)
|
||||
compiling? &s:keep &s:temp choose &s:to-float class:word ; immediate
|
||||
~~~
|
||||
|
||||
|
|
BIN
ngaImage
BIN
ngaImage
Binary file not shown.
|
@ -56,7 +56,7 @@ This contains the list of files for the chapters in the book.
|
|||
{ 'Historical_Papers 'tech-notes/historical-papers }
|
||||
{ 'Metacompiling 'tech-notes/metacompilation }
|
||||
{ 'Self-Hosting 'tech-notes/self-hosting }
|
||||
{ 'Prefixes 'tech-notes/prefixes }
|
||||
{ 'Sigils 'tech-notes/prefixes }
|
||||
{ 'Kernel_Words 'tech-notes/kernel-words }
|
||||
{ 'Ngaro_to_Nga 'tech-notes/ngaro-to-nga }
|
||||
{ 'RETRO11_Retrospective 'tech-notes/retro11-retrospective }
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue