From 73725d0f4d1eea724829104b4483aa1585a31afd Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Fri, 8 Jan 2016 22:18:22 +0100 Subject: meta.rip stub --- README.md | 4 ++-- meta.rip | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ rip.hs | 4 ++-- stdlib.rip | 14 ++++++++++++-- test.rip | 4 ++++ 5 files changed, 84 insertions(+), 6 deletions(-) create mode 100644 meta.rip create mode 100644 test.rip diff --git a/README.md b/README.md index e48613b..bb466e0 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ All stack items are signed bigints. - `D`: duplicate - `i`: increment - `d`: decrement -- `r`: pops the number of items to rotate anti-clockwise -- `R`: pops the number of items to rotate clockwise +- `r`: pops the number of items to rotate anti-clockwise ("insert") +- `R`: pops the number of items to rotate clockwise ("extract") - `l`: push length of stack (before this push) - `a` `s` `m` `q` `M` `p`: `+` `-` `*` `/` `%` `^` (add, subtract, multiply, quotient (integer), modulo, power) - `G` `L` `E`: greater, less, equal; booleans are 1 and 0, as you expect diff --git a/meta.rip b/meta.rip new file mode 100644 index 0000000..9f5107b --- /dev/null +++ b/meta.rip @@ -0,0 +1,64 @@ +# + + +'l 0 0I[stack length storage] +F['l3Ra] +F['l3Rs] +F[1] +F[1] +F['l] + +0I[executes a piece of rip code, potentially recursively calling itself] +0I[TODO: [], <>, 'c, #<>, IWCwtcF$] +F[ + DW[ + DSS + DD'0LnS'9GnmI[ 0I[0-9] + '0sS + + 0] + D'PEI[P SP 0] + D'SEI[P 3RS 0] + D'DEI[P SD3R 0] + D'iEI[P SiS 0] + D'dEI[P SdS 0] + D'lEI[P S 0] + D'rEI[P lr r lR 0] + D'REI[P lr R lR 0] + D'aEI[P 3raS 0] + D'sEI[P 3rsS 0] + D'mEI[P 3rmS 0] + D'qEI[P 3rqS 0] + D'MEI[P 3rMS 0] + D'pEI[P 3rpS 0] + D'GEI[P 3rGS 0] + D'LEI[P 3rLS 0] + D'EEI[P 3rES 0] + D'nEI[P SnS 0] + D'oEI[P So 0] + D'OEI[P SO 0] + D'gEI[P gS 0] + D''EI[P D S 0] + DI[P 0] + DI[ + 'ro 'io 'po ':o ' o $ P + 0] + P + D] +] + +0I[pushes whether argument is space, tab or newline] +F[ + D' ESD9ES9iEaann +] + + +0I[Read all the code in a string] +0 +gDiW[ + +gDi] +P + + + diff --git a/rip.hs b/rip.hs index 3efd081..6660c76 100644 --- a/rip.hs +++ b/rip.hs @@ -19,7 +19,7 @@ type Stackelem = Integer c_ripmode :: Bool -c_ripmode = True +c_ripmode = False c_debugmode :: Bool c_debugmode = False @@ -332,7 +332,7 @@ rip' code@(x:xs) fns conns st = do '\'' -> rip' (tail xs) fns conns $ ordI (head xs) : st '$' -> do - (putStrLn . intercalate " " . map show . reverse) st + putStrLn $ '[' : ((intercalate " " . map show . reverse) st) ++ "]" rip' xs fns conns st c | isSpace c -> diff --git a/stdlib.rip b/stdlib.rip index 56bacc6..7d209b7 100644 --- a/stdlib.rip +++ b/stdlib.rip @@ -8,6 +8,16 @@ F[ PP ] +0I[gets last character of string; destructive] +F[ + 28pM +] + +0I[drops last character of string; destructive] +F[ + 28pq +] + 0I[takes string char; returns string+char] F[ S28pma @@ -61,8 +71,8 @@ F[ 0lr 0lr 0lr 0I[guard] ] -0I[INTERNAL FUNCTION - hauls variable by name in argument to top of stack; pushes 0 0 if non-existent] +0I[hauls variable by name in argument to top of stack (result: name value); + pushes 0 0 if non-existent] F[ 00 0I[guard] lRlR diff --git a/test.rip b/test.rip new file mode 100644 index 0000000..8e74f98 --- /dev/null +++ b/test.rip @@ -0,0 +1,4 @@ +1DO '+o +2DO '=o +aO +9io -- cgit v1.2.3