should ignore html

This commit is contained in:
chakr 2023-02-19 11:20:24 -05:00
parent 9e4eac6f12
commit ec4f3c8341
2 changed files with 2 additions and 394 deletions

3
.gitignore vendored
View File

@ -1 +1,2 @@
bin/*
bin/*
*.html

393
SPEC.html
View File

@ -1,393 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>1 Language Overview</title>
<style>
/* From extension vscode.github */
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
.vscode-dark img[src$=\#gh-light-mode-only],
.vscode-light img[src$=\#gh-dark-mode-only] {
display: none;
}
</style>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Microsoft/vscode/extensions/markdown-language-features/media/markdown.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Microsoft/vscode/extensions/markdown-language-features/media/highlight.css">
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe WPC', 'Segoe UI', system-ui, 'Ubuntu', 'Droid Sans', sans-serif;
font-size: 14px;
line-height: 1.6;
}
</style>
<style>
.task-list-item {
list-style-type: none;
}
.task-list-item-checkbox {
margin-left: -20px;
vertical-align: middle;
}
</style>
</head>
<body class="vscode-body vscode-light">
<h1 id="varaq-specification"><em>var'aq</em> Specification</h1>
<p>For better flavor text please read the <a href="https://www.oocities.org/connorbd/varaq/varaqspec.html">Original <code>var'aq</code> spec</a> the following is a trimmed down version of the spec with a couple of fixes and addendums to how this implementation of the language works.</p>
<h2 id="1-language-overview">1 Language Overview</h2>
<p><em>var'aq</em> is a stack-based, RPN programming language with points of similarity to Lisp, Forth, and PostScript. It is more of a functional language than an imperative (Algol-like) language; most operations are dependent on the stack and bypass the local variable store altogether.</p>
<h3 id="12-filetypes">1.2 Filetypes</h3>
<ul>
<li><code>.vq -- application/varaq</code> -- a standard <em>var'aq</em> source file</li>
<li><code>.vqe -- application/varaq-engl</code> -- an English-keyword <em>var'aq</em> source file</li>
</ul>
<h2 id="2-language-basics">2 Language Basics</h2>
<p>This section describes the fundamental <em>var'aq</em> language constructs and data types.</p>
<h3 id="21-stack-operations">2.1 Stack Operations</h3>
<p>These operations directly manipulate the <em>var'aq</em> operand stack. The operand stack can hold any of four kinds of data: numbers (real or integer), strings, functions, or arrays. It is best described as &quot;translucent&quot;, similar to the transparent stack of Forth or PostScript but somewhat more restricted. The internal data representation of the stack is not available to the programmer.</p>
<h4 id="211-popwod">2.1.1 pop/woD</h4>
<p><em>obj <code>woD</code> -</em></p>
<p>Pops and discards the top item on the stack. The literal meaning is <em>discard</em>.</p>
<p>Errors: stackUnderflow</p>
<h4 id="212-duplatlh">2.1.2 dup/latlh</h4>
<p><em>obj <code>latlh</code> obj obj</em></p>
<p>Duplicates the top object on the stack.</p>
<p>Errors: stackUnderflow</p>
<h4 id="213-exchtam">2.1.3 exch/tam</h4>
<p><em>obj1 obj2 <code>tam</code> obj2 obj1</em></p>
<p>Inverts the order of the top two objects on the stack.</p>
<p>Errors: stackUnderflow</p>
<h4 id="214-clearchimmoh">2.1.4 clear/chImmoH</h4>
<p><em>... obj <code>chIm</code> -</em></p>
<p>Empties the stack.</p>
<p>Errors: none</p>
<h4 id="215-rememberqaw">2.1.5 remember/qaw</h4>
<p><em>- <code>qaw</code> flag</em></p>
<p>Puts a flag (like PostScript's <code>mark</code>) on the stack. The internal representation of the flag is not available to the programmer.</p>
<p>Errors: none</p>
<h4 id="216-forgetqawha">2.1.6 forget/qawHa'</h4>
<p><em>... flag ... <code>qawHa'</code> ...</em></p>
<p>Clears the stack down to the flag and pops the flag. If there is no flag present, the stack is emptied completely.</p>
<p>Errors: none</p>
<h4 id="217-dumphotlh-lit-scan">2.1.7 dump/Hotlh (lit. scan)</h4>
<p><em>... <code>Hotlh</code> ...</em></p>
<p>Prints the contents of the operand stack to STDOUT without changing them. <em>Note</em>: the <em>Hotlh</em> operator is a debugging operator and is not intended for use in programs; it is merely documented here because it might be useful to a <em>var'aq</em> developer. In particular, the output format of this operator is implementation-defined and will not be specified in this document. <em>Hotlh</em> may be redefined to take such arguments as the implementor feels appropriate.</p>
<p>Errors: implementation-defined.</p>
<h4 id="218-disinter">2.1.8 disinter</h4>
<p>Returns the value just above the top mark on the stack without disturbing the stack above it.</p>
<h3 id="22-datacode-operations">2.2 Data/Code Operations</h3>
<p><em>var'aq</em>, like many similar languages, does not distinguish between code and data. These operations include operators to associate names with objects and executable procedures, as well as operators to define and manage data structures. Note that variables and procedures live in a common namespace, since the act of pushing the content of a variable is essentially the same as executing the variable's name.</p>
<h4 id="221--quotelimoh">2.2.1 ~ (quote/lI'moH)</h4>
<p><em>- <code>~</code> obj obj</em></p>
<p>The ~ operator is a special form, as it is not a postfix operator. When the interpreter encounters a ~, it pushes the next token on the stack as is regardless of whether it is a defined name. (Attempting to push an undefined name without a ~ will generate an undefinedName error.)</p>
<p>The literal meaning of this operator's name is &quot;make useful&quot;. Errors: none</p>
<h4 id="222-">2.2.2 {</h4>
<p>Begins the creation of an anonymous procedure. The process is implementation-dependent.</p>
<h4 id="223-">2.2.3 }</h4>
<p><em>- <code>}</code> proc</em></p>
<p>Completes procedure construction and pushes a reference to the completed procedure on the stack. Does not execute the procedure.</p>
<p>Errors: noDefinedProc</p>
<h4 id="224-namepong">2.2.4 name/pong</h4>
<p><em>obj id <code>pong</code> -</em></p>
<p>Associates <em>obj</em> with <em>id</em> and places it in the system lookup space. Conventionally used to associate new operator names with procedure objects.</p>
<p>Example: <em>~ add3 { boq boq cha' } pong</em></p>
<p>Pushes the name <em>add3</em> and a procedure object on the stack, then binds the name to the procedure.</p>
<p>Errors: stackUnderflow, noDefinedProc</p>
<h4 id="225-setcher">2.2.5 set/cher</h4>
<p><em>obj id <code>cher</code> -</em></p>
<p>Reassigns the value of a value already in the system lookup space. Used primarily for variable assignments.</p>
<p>Errors: stackUnderflow, noSuchName</p>
<h4 id="226----comment">2.2.6 (* ... *) (comment)</h4>
<p>Marks a comment in a program. All such comments are treated as single tokens and ignored.</p>
<h4 id="227-name">2.2.7 //<em>name</em></h4>
<p>Causes the interpreter to import a file with the name <em>name</em>.vq(e) and execute it as if it is part of the currently executing program. Essentially equivalent to <code>#include</code> in C.</p>
<p>An example can be found at the top of the <a href="./examples/test.vqe">test.vqe</a> example.</p>
<p><code>Note:</code> you must use either absolute paths or paths relitive to the location of the interpeter</p>
<h3 id="23-control-flow">2.3 Control Flow</h3>
<p><em>var'aq</em> supports a small but sufficient supply of conditional and iterative operators.</p>
<h4 id="231-ifyeshijachugh">2.3.1 ifyes/HIja'chugh</h4>
<p><em>bool proc <code>HIja'chugh</code> -</em></p>
<p>Pops the proc object off the stack, then evaluates the boolean. If it's true, the proc object is evaluated; otherwise, it's thrown out.</p>
<p>Errors: stackUnderflow, noDefinedProc</p>
<h4 id="232-ifnoghobechugh">2.3.2 ifno/ghobe'chugh</h4>
<p><em>bool proc <code>ghobe'chugh</code> -</em></p>
<p>Similar to <em>HIja'chugh</em> above, but executes proc only if bool is false.</p>
<p>Errors: stackUnderFlow, noDefinedProc</p>
<h4 id="233-choosewiv">2.3.3 choose/wIv</h4>
<p><em>bool <code>wIv</code> bool bool</em></p>
<p>Duplicates a boolean value on top of the stack. Allows paired HI'ja'chugh/ghobe'chugh clauses.</p>
<p><code>Note:</code> To the untrained eye, it may seem as though wIv and latlh are identical. This is true in the reference implementation, but may not be in any version that actually does some level of type checking. This bit of syntactic sugar should never be relied upon; always use wIv in this situation.</p>
<h4 id="234-evalchov">2.3.4 eval/chov</h4>
<p><em>proc <code>chov</code> -</em></p>
<p>Pops a proc object off the stack and executes it.</p>
<p>Errors: stackUnderflow, noDefinedProc</p>
<h4 id="235-escapenargh">2.3.5 escape/nargh</h4>
<p><em>bool <code>nargh</code> -</em></p>
<p>Exit the current procedure. Useful for exit conditions on loops. Will terminate the current session if used top-level.</p>
<h4 id="236-repeatvangqa">2.3.6 repeat/vangqa'</h4>
<p><em>val proc <code>vangqa'</code> -</em></p>
<p>Pops val and proc off the stack and executes proc val times.</p>
<h3 id="24-list-operations">2.4 List Operations</h3>
<p><em>var'aq</em> supports a series of operators for management of lists (<em>ghomHom</em>, which seems to mean something like &quot;cluster&quot;). These primitives are the language's primary way of managing aggregate objects and work much like similar operators in LISP; a more sophisticated paradigm, such as OO extensions or the like, can be built with these operators.</p>
<p>Note that &quot;objects&quot; as they stand in <em>var'aq</em> are largely singletons as in JavaScript; there is no inherent concept of object-orientation or anything like it in standard <em>var'aq</em>.</p>
<h4 id="241-">2.4.1 (</h4>
<p>Begins a list definition.</p>
<h4 id="242-">2.4.2 )</h4>
<p><em>( item1 item2 ... <code>)</code> list</em></p>
<p>Creates a list and pushes it onto the stack.</p>
<h4 id="243-splitsij">2.4.3 split/SIj</h4>
<p><em>list <code>SIj</code> item1 list</em></p>
<p>Pops a list off the stack and returns the first item and the rest of the list.</p>
<h4 id="244-consmuv">2.4.4 cons/muv</h4>
<p><em>list item1 ... <code>muv</code> list</em></p>
<p>Takes an object and adds it to the head of a list. Equivalent to the LISP <code>cons</code> operator.</p>
<h4 id="245-shatterghorqu">2.4.5 shatter/ghorqu'</h4>
<p><em>list <code>ghorqu'</code> item1 item2 ...</em></p>
<p>Reduces a list to its component elements and pushes them on the stack in order.</p>
<p><code>Note:</code> The precise meaning of the construction <em>ghorqu'</em> is a bit obscure; the rendering <em>shatter</em> is idiomatic and may derive from a nonstandard dialect. Standard Klingon would generally prefer <em>jor</em>, meaning <em>explode</em>.)</p>
<h4 id="246-emptychima">2.4.6 empty?/chIm'a'</h4>
<p><em>list <code>chIm'a'</code> bool</em></p>
<p>Examines a list on the stack and returns 1 if its value is null (<em>pagh</em>), a 0 if it contains anything.</p>
<h4 id="247-consume">2.4.7 consume</h4>
<p><em>obj1 obj2 ... mark <code>consume</code> list</em></p>
<p>Pops all objects on the stack down to <em>mark</em> and returns them in a list.</p>
<p><code>Note:</code> some implementations also have an operator known as bite/<em>chop</em>, equivalent to the Lisp <em>cdr</em>. This is not required in any standard <em>var'aq</em> implementation and can easily be rendered by the function</p>
<pre><code>~ chop { SIj woD } pong
</code></pre>
<h3 id="25-string-operators">2.5 String Operators</h3>
<p><em>tlheghjangwI'mey</em></p>
<h4 id="251-strtietlheghrar">2.5.1 strtie/tlheghrar</h4>
<p><em>str1 str2 <code>tlheghrar</code> str3</em></p>
<p>Concatenates the top two strings on the stack into one.</p>
<h4 id="252-composenaqmoh">2.5.2 compose/naQmoH</h4>
<p><em>mark str1 str2 ... strn <code>naQmoH</code> strn'</em></p>
<p>Pops objects (executing proc objects if necessary) off the stack until a marker (placed by <code>qaw</code>) is hit and combines them into one string.</p>
<h4 id="253-streqtlheghrapa">2.5.3 streq?/tlheghrap'a'</h4>
<p><em>str1 str2 <code>tlheghrap'a'</code> bool</em></p>
<p>Pops the top two strings on the stack, compares them, and returns 1 if identical, 0 if not.</p>
<h4 id="254-strcuttlheghpe">2.5.4 strcut/tlheghpe'</h4>
<p><em>str startval endval <code>tlheghpe'</code> substr</em></p>
<p>Pops two values and a string and returns the section of the string between character <em>startval</em> and character <em>endval</em>.</p>
<h4 id="255-strmeasuretlheghjuv">2.5.5 strmeasure/tlheghjuv</h4>
<p><em>str <code>tlheghjuv</code> val</em></p>
<p>Pops a string off the stack and returns its length in characters.</p>
<h4 id="256-explodejor">2.5.6 explode/jor</h4>
<p><em>str <code>jor</code> list</em></p>
<p>Separates individual &quot;words&quot; in a string by whitespace.</p>
<h2 id="3-mathematical-operators">3 Mathematical Operators</h2>
<p><em>mI'jangwI'mey</em></p>
<h3 id="31-arithmetic-operations">3.1 Arithmetic Operations</h3>
<p><em>toghwI'mey</em></p>
<p>Arithmetic operators usually work with real numbers unless otherwise stated. The number operators (sec 3.3) can convert them to integers if necessary.</p>
<h4 id="311-addboq">3.1.1 add/boq</h4>
<p><em>a b <code>boq</code> sum</em></p>
<p>Pops the top two values on the stack and replaces them with their sum.</p>
<h4 id="312-subboqha">3.1.2 sub/boqHa'</h4>
<p><em>a b <code>boqHa'</code> difference</em></p>
<p>Pops the top two values on the stack and replaces them with a - b.</p>
<h4 id="313-mulboqegh">3.1.3 mul/boq'egh</h4>
<p><em>a b <code>boq'egh</code> product</em></p>
<p>Pops the top two values on the stack and replaces them with their product.</p>
<h4 id="314-divboqhaegh">3.1.4 div/boqHa''egh</h4>
<p><em>a b <code>wav</code> quotient</em></p>
<p>Pops the top two values on the stack and replaces them with a/b.</p>
<h4 id="315-idivhabboqhaegh-lit-full-divide">3.1.5 idiv/HabboqHa''egh (lit. full-divide)</h4>
<p><em>a b <code>HabboqHa''egh</code> quotient</em></p>
<p>Pops the top two values on the stack and replaces them with the results of an integer division operation.</p>
<h4 id="316-modchuv-lit-leftover">3.1.6 mod/chuv (lit. leftover)</h4>
<p><em>a b <code>chuv</code> remainder</em></p>
<p>Pops the top two values and returns the remainder of a mod b.</p>
<h4 id="317-powboqhaqa-lit-remultiply">3.1.7 pow/boqHa'qa' (lit. remultiply)</h4>
<p><em>base exp <code>boqHa'qa'</code> real</em></p>
<p>Pops the top two values and returns base^exp.</p>
<h4 id="318-sqrtlosar-lit-fourth-howmuch">3.1.8 sqrt/loS'ar (lit. fourth-howmuch)</h4>
<p><em>angle <code>loS'ar</code> real</em></p>
<p>Returns the square root of val.</p>
<h4 id="319-add1waboq">3.1.9 add1/wa'boq</h4>
<p><em>a <code>wa'boq</code> a+1</em></p>
<p>Increments the top value on the stack by one.</p>
<h4 id="3110-sub1waboqha">3.1.10 sub1/wa'boqHa'</h4>
<p><em>a <code>wa'boqHa'</code> a-1</em></p>
<p>Decrements the top value on the stack by one.</p>
<h3 id="32-trigonometric-and-logarithmic-operators">3.2 Trigonometric and Logarithmic Operators</h3>
<p><em>SIHpojjangwI'mey 'ej ghurjangwI'mey</em></p>
<h4 id="321-sinyuegh-lit-wave">3.2.1 sin/yu'egh (lit. wave)</h4>
<p><em>angle <code>yu'egh</code> real</em></p>
<p>Returns the sine of val.</p>
<h4 id="322-cosyueghha-lit-counter-wave">3.2.2 cos/yu'eghHa' (lit. counter-wave)</h4>
<p><em>angle <code>yu'eghHa'</code> cos(val)</em></p>
<p>Returns the cosine of val.</p>
<h4 id="323-tanqojmi-lit-cliffnumber">3.2.3 tan/qojmI' (lit. cliffnumber)</h4>
<p><em>angle <code>qojmI'</code> tan(val)</em></p>
<p>Returns the tangent of val.</p>
<h4 id="324-atanqojha-lit-anticliff">3.2.4 atan/qojHa' (lit. anticliff)</h4>
<p><em>num den <code>qojHa'</code> angle</em></p>
<p>Returns the arctangent of <em>num / den</em>.</p>
<h4 id="325-lnghurtah">3.2.5 ln/ghurtaH</h4>
<p><em>num <code>ghurtaH</code> real</em></p>
<p>Returns the natural log of <em>num</em>.</p>
<h4 id="326-logmahghurtah">3.2.6 log/maHghurtaH</h4>
<p><em>num <code>maHghurtaH</code> real</em></p>
<p>Returns the base 10 log of <em>num</em>.</p>
<h4 id="327-log3wejghurtah">3.2.7 log3/wejghurtaH</h4>
<p><em>num <code>wejghurtaH</code> real</em></p>
<p>Returns the base 3 log of <em>num</em>.</p>
<h3 id="33-numerical-operators-and-constants">3.3 Numerical Operators and Constants</h3>
<p>This section describes operators that operate on numbers themselves, as well as common system-level constants.</p>
<h4 id="331-clippod">3.3.1 clip/poD</h4>
<p><em>real <code>poD</code> int</em></p>
<p>Removes the fractional portion of a real number (equivalent to floor(real).</p>
<h4 id="332-smoothhab-lit-smooth">3.3.2 smooth/Hab (lit. smooth)</h4>
<p><em>real <code>Hab</code> int</em></p>
<p>Rounds a number to the nearest integer.</p>
<h4 id="333-howmuchar">3.3.3 howmuch/'ar</h4>
<p><em>num <code>'ar</code> num2</em></p>
<p>Returns the absolute value of <em>num</em>.</p>
<h4 id="334-setrandmischer">3.3.4 setrand/mIScher</h4>
<p><em>num <code>mIScher</code> -</em></p>
<p>Sets the random number generator seed value to <em>num</em>. Not common, since most <em>var'aq</em> implementations have a rather arcane formula for picking a pseudo-random seed value.</p>
<h4 id="335-randmis">3.3.5 rand/mIS</h4>
<p><em>num <code>mIS</code> real</em></p>
<p>Returns a random real number in the range 0 to <em>num</em>. If there is no meaningful input on the stack,</p>
<h4 id="336-pihehmi">3.3.6 pi/HeHmI'</h4>
<p>Pushes the value pi (~3.14159...) onto the stack. The Klingon name literally means &quot;edge-number&quot;.</p>
<h4 id="337-eghurmi">3.3.7 e/ghurmI'</h4>
<p>Pushes the value e onto the stack. The Klingon name literally means &quot;growth-number&quot;.</p>
<h4 id="338-inthabmia">3.3.8 int?/HabmI''a'</h4>
<p><em>val <code>HabmI''a'</code> bool</em> Pops the top value on the stack and returns 1 if it is an integer, 0 if not.</p>
<h4 id="339-numbermia">3.3.9 number?/mI''a'</h4>
<p><em>val <code>mI''a'</code> bool</em></p>
<p>Pops the top value off the stack and returns 1 if it's a number, 0 if it's something else.</p>
<h4 id="3310-numberizemimoh">3.3.10 numberize/mI'moH</h4>
<p><em>str <code>mi'moH</code> val</em></p>
<p>Pops a string off the stack, converts it into a numerical value, and returns it.</p>
<h4 id="34-bitwise-operators">3.4 Bitwise operators</h4>
<p>Though <em>var'aq</em> makes no clear distinction between integers and reals, it is nevertheless useful to be able to manipulate a number on the bit level. The following operators assume that their operands will always be treated as integers; effects on floating-point values are undefined, and may be disallowed at the implementor's discretion.</p>
<h4 id="341-isolatemobmoh">3.4.1 isolate/mobmoH</h4>
<p><em>a b <code>mobmoH</code> result</em></p>
<p>Performs a bitwise AND on a and b.</p>
<h4 id="342-mixdud">3.4.2 mix/DuD</h4>
<p><em>a b <code>DuD</code> result</em></p>
<p>Performs a bitwise OR on a and b.</p>
<h4 id="343-contradicttlhoch">3.4.3 contradict/tlhoch</h4>
<p><em>a b <code>tlhoch</code> result</em></p>
<p>Performs a bitwise XOR on a and b.</p>
<h4 id="344-complqomoh">3.4.4 compl/Qo'moH</h4>
<p><em>val <code>Qo'moH</code> ~val</em></p>
<p>Returns the one's-complement of val. <code>Note:</code> The literal meaning is something like &quot;make it say no&quot;.</p>
<h4 id="345-shiftrightnihghos">3.4.5 shiftright/nIHghoS</h4>
<p><em>a b <code>nIHghoS</code> result</em></p>
<p>Shifts a right b places, preserving the sign of the value.</p>
<h4 id="346-shiftleftposghos">3.4.6 shiftleft/poSghoS</h4>
<p><em>a b <code>poSghoS</code> result</em></p>
<p>Shifts a left b places.</p>
<h3 id="4-relational-and-logical-operators">4 Relational and Logical Operators</h3>
<h4 id="41-relational-operators-and-predicate-functions">4.1 Relational Operators and Predicate Functions</h4>
<p><em>yu'jangwI'mey</em></p>
<h4 id="411-gtlawa">4.1.1 gt?/law''a'</h4>
<p><em>a b <code>law''a'</code> bool</em></p>
<p>Pops a and b off the stack, compares them, and returns a boolean value of true if a is larger.</p>
<h4 id="412-ltpusa">4.1.2 lt?/puS'a'</h4>
<p><em>a b <code>puS'a'</code> bool</em></p>
<p>Pops a and b off the stack, compares them, and returns a boolean value of true if a is smaller.</p>
<h4 id="413-eqrapa">4.1.3 eq?/rap'a'</h4>
<p><em>a b <code>rap'a'</code> bool</em></p>
<p>Pops a and b off the stack, compares them, and returns a boolean value of true if a is the same as b.</p>
<h4 id="414-gelawrapa">4.1.4 ge?/law'rap'a'</h4>
<p><em>a b <code>law'rap'a'</code> bool</em></p>
<p>Pops a and b off the stack, compares them, and returns a boolean value of true if a is greater than or equal to b.</p>
<h4 id="415-lepusrapa">4.1.5 le?/puSrap'a'</h4>
<p><em>a b <code>puSrap'a'</code> bool</em></p>
<p>Pops a and b off the stack, compares them, and returns a boolean value of true if a is less than or equal to b.</p>
<h4 id="416-nerapbea">4.1.6 ne?/rapbe'a'</h4>
<p><em>a b <code>rapbe'a'</code> bool</em></p>
<p>Pops a and b off the stack, compares them, and returns a boolean value of true if a is not equal to b.</p>
<h4 id="417-nullpagha">4.1.7 null?/pagh'a'</h4>
<p><em>obj <code>pagh'a'</code> bool</em></p>
<p>Examines the top object on the stack and returns a 1 if null, a 0 if not.</p>
<h4 id="418-negativetaha">4.1.8 negative?/taH'a'</h4>
<p><em>val <code>taH'a'</code> bool</em></p>
<p>Pops the top number on the stack and returns a 1 if less than 0, a 0 if not.</p>
<h4 id="42-logical-operators">4.2 Logical Operators</h4>
<p><em>vItjangwI'mey</em></p>
<p>Note that these are strictly logical operators, not bitwise.</p>
<h4 id="421-andje">4.2.1 and/je</h4>
<p><em>a b <code>je</code> bool</em></p>
<p>Evaluates b and a and returns a 1 if both are true, a 0 if not.</p>
<h4 id="422-orjoq">4.2.2 or/joq</h4>
<p><em>a b <code>joq</code> bool</em></p>
<p>Evaluates b and a and returns a 1 if one or both are true, a 0 if both are false.</p>
<h4 id="423-xorghap">4.2.3 xor/ghap</h4>
<p><em>a b <code>ghap</code> bool</em></p>
<p>Evaluates b and a and returns a 1 if only one is true, a 0 otherwise.</p>
<h4 id="424-notghobe">4.2.4 not/ghobe'</h4>
<p><em>val <code>ghobe'</code> bool</em></p>
<p>Evaluates val and returns 1 if true, 0 if not.</p>
<h3 id="5-inputoutput-and-file-operators">5 Input/Output and File Operators</h3>
<p>The <em>var'aq</em> Level 0 specification essentially handles console I/O and files in a manner very similar to the UNIX model.</p>
<h4 id="51-console-io">5.1 Console I/O</h4>
<p>The console I/O model at this point is very simple: write, read, error.</p>
<h4 id="511-dispcha">5.1.1 disp/cha'</h4>
<p><em>obj <code>cha'</code> -</em></p>
<p>Pops the top object on the stack and writes it to STDOUT. Note that certain types of objects will generate meaningless output, particularly anonymous proc objects.</p>
<h4 id="512-listenij">5.1.2 listen/'Ij</h4>
<p><em>- <code>'Ij</code> str</em></p>
<p>Reads one line of input and stores it as a string on top of the stack.</p>
<h4 id="513-complainbep">5.1.3 complain/bep</h4>
<p><em>str <code>bep</code> -</em></p>
<p>Pops <em>str</em> and prints it to stderr.</p>
<h3 id="6-system-variables">6 System Variables</h3>
<p><em>patSarwI'mey</em></p>
<p>This section describes <em>var'aq</em> keywords that do no more than put set values on the stack. Many of them are not precisely constants but more like environment variables.</p>
<h4 id="61-io-related-constants">6.1 I/O-related Constants</h4>
<h4 id="611-newlinechudonwi">6.1.1 newline/chu'DonwI'</h4>
<p><em>- <code>chu'DonwI'</code> '\n'</em></p>
<p>Prints a carriage return.</p>
<h4 id="612-tabchutut">6.1.2 tab/chu'tut</h4>
<p><em>- <code>chu'DonwI'</code> '\t'</em></p>
<p>Advances by one tab stop.</p>
<h4 id="62-environment-constants">6.2 Environment Constants</h4>
<h4 id="621-whereaminuqdaq_jih">6.2.1 whereami/nuqDaq_jIH</h4>
<p><em>- <code>nuqDaq_jIH</code> &quot;string of your local ip address&quot;</em></p>
<p>Returns the IP address of the machine the interpreter is running on.</p>
<h4 id="622-versionpongmi">6.2.2 version/pongmI'</h4>
<p><em>- <code>pongmI'</code> &quot;string of version&quot;</em></p>
<p>Returns the current interpreter version number. The reference interpreter returns a date stamp.</p>
<h4 id="623-argvtaghde">6.2.3 argv/taghDe'</h4>
<p><em>- <code>taghDe'</code> (arg1, arg2, ...)</em></p>
<p>Pushes the command line arguments on the stack as a list.</p>
<h2 id="7-new-operators">7 New Operators</h2>
<p>The following are all new operators that are not included in the original perl implementation of <em>var'aq</em></p>
<h3 id="71-stack-operations">7.1 Stack Operations</h3>
<p>These are stolen directly from <em>Forth</em> (specifically the <a href="http://www.forth.org/Ting/Forth-for-the-Complete-Idiot/Forth-79-Handy-Reference.pdf"><em>FORTH-79 Handy Reference</em></a> from the book <em>Forth for the Complete Idiot</em>),</p>
<p>They are very useful for doing operations without clobbering the stack</p>
<h4 id="711-overqi">7.1.1 over/QI</h4>
<p><em>obj1 obj2 <code>QI</code> obj1 obj2 obj1</em></p>
<p>Make a copy of the second item on top of the stack.</p>
<p>The direct Klingon translation for <code>QI</code> is bridge, as in a bridge over a river, which works close enough.</p>
<p>Errors: stackUnderflow</p>
<h4 id="712-pickwoh">7.1.2 pick/woH</h4>
<p><em>N <code>woH</code> objN</em></p>
<p>Make a copy of the Nth item on top of the stack.</p>
<p>For example <em>1 <code>woH</code></em> is the same as <code>latlh</code> &amp; <em>2 <code>woH</code></em> is the same as <code>QI</code></p>
<p>Errors: stackUnderflow, stackOverflow</p>
<h4 id="713-rotjir">7.1.3 rot/jIr</h4>
<p><em>obj1 obj2 obj3 <code>jIr</code> obj2 obj3 obj1</em></p>
<p>Rotate the third item to the top of the stack.</p>
<p>Errors: stackUnderflow</p>
<h4 id="714-depthjuv">7.1.4 depth/juv</h4>
<p><em>- <code>juv</code> num</em></p>
<p>Count the number of items on the stack and push that number to the top of the stack.</p>
<p>Errors: stackUnderflow</p>
</body>
</html>