Execute SNUSP/Tcl: Difference between revisions
m
Fixed syntax highlighting.
(Added implementation notes) |
m (Fixed syntax highlighting.) |
||
(7 intermediate revisions by 2 users not shown) | |||
Line 1:
{{implementation|SNUSP}}{{collection|RCSNUSP}}[[
Historically, the Bloated interpreter was evolved from the Modular interpreter, which in turn was evolved from the Core interpreter.
The most interesting feature of the '''Core''' interpreter is that it models the data store as an unbounded half-line (implemented in a [[Tcl]] list), dynamically extending it “on the right” to have as many cells as necessary. Also, when a failure occurs (going outside the program space, going before the start of the data store) then a multi-level “break” exception is thrown to make the main loop exit.
The '''Modular''' interpreter adds a basic stack; it is not very much more interesting than the Core interpreter but was immediately evolved from it in order to be able to read the majority of SNUSP programs that exist out there (this is the most common dialect).
The interpreter for '''Bloated'''
<br clear=all>
===Core [[SNUSP]]===
<
# Basic I/O to read the program data and get ready for execution
Line 85:
"-" {Set [expr [Get]-1]}
"." {puts -nonewline [format %c [set last [Get]]]}
"," {Set [scan [read stdin 1] %c]}
}
Move
}
if {$last != 10} {puts ""}</
===Modular [[SNUSP]]===
<
# Basic I/O to read the program data and get ready for execution
Line 184:
"-" {Set [expr [Get]-1]}
"." {puts -nonewline [format %c [set last [Get]]]}
"," {Set [scan [read stdin 1] %s]}
"@" {Push}
"#" {Pop}
Line 190:
Move
}
if {$last != 10} {puts ""}</
===Bloated [[SNUSP]]===
<
# Basic I/O to read the program data and get ready for execution
Line 326 ⟶ 327:
}
}
if {$last != 10} {puts ""}</
===Test Code===
====Samples of Bloated SNUSP====
This prints out a random number of random length:
<pre><nowiki>$!/+++++++++%++++++++++++++++++++++++++++++++++++++++++++++++.!/-\
|