From 8ca5996031b5216cc518cc3f3bb6ece672424786 Mon Sep 17 00:00:00 2001 From: Nicolas Ayache Date: Wed, 9 Nov 2022 23:44:53 +0100 Subject: [PATCH 1/2] Doc/Michelson: redirect control structures to interactive reference. --- docs/alpha/michelson.rst | 103 ++------------------------------------- 1 file changed, 3 insertions(+), 100 deletions(-) diff --git a/docs/alpha/michelson.rst b/docs/alpha/michelson.rst index 53d581dbf42a..6115560e7284 100644 --- a/docs/alpha/michelson.rst +++ b/docs/alpha/michelson.rst @@ -509,115 +509,18 @@ Core instructions Control structures ~~~~~~~~~~~~~~~~~~ -- ``FAILWITH``: Explicitly abort the current program. - -:: - - :: 'a : \_ -> \_ - -This special instruction aborts the current program exposing the top -element of the stack in its error message (first rule below). It makes -the output useless since all subsequent instructions will simply -ignore their usual semantics to propagate the failure up to the main -result (second rule below). Its type is thus completely generic. - -:: - - > FAILWITH / a : _ => [FAILED] - > _ / [FAILED] => [FAILED] +A detailed description of the following instructions can be found in the `interactive Michelson reference manual `__. +- ``FAILWITH``: Explicitly abort the current program. - ``{}``: Empty sequence. - -:: - - :: 'A -> 'A - - > {} / SA => SA - - ``{ I ; C }``: Sequence. - -:: - - :: 'A -> 'C - iff I :: [ 'A -> 'B ] - C :: [ 'B -> 'C ] - - > I ; C / SA => SC - where I / SA => SB - and C / SB => SC - - ``IF bt bf``: Conditional branching. - -:: - - :: bool : 'A -> 'B - iff bt :: [ 'A -> 'B ] - bf :: [ 'A -> 'B ] - - > IF bt bf / True : S => bt / S - > IF bt bf / False : S => bf / S - - ``LOOP body``: A generic loop. - -:: - - :: bool : 'A -> 'A - iff body :: [ 'A -> bool : 'A ] - - > LOOP body / True : S => body ; LOOP body / S - > LOOP body / False : S => S - - ``LOOP_LEFT body``: A loop with an accumulator. - -:: - - :: (or 'a 'b) : 'A -> 'b : 'A - iff body :: [ 'a : 'A -> (or 'a 'b) : 'A ] - - > LOOP_LEFT body / (Left a) : S => body ; LOOP_LEFT body / a : S - > LOOP_LEFT body / (Right b) : S => b : S - - ``DIP code``: Runs code protecting the top element of the stack. - -:: - - :: 'b : 'A -> 'b : 'C - iff code :: [ 'A -> 'C ] - - > DIP code / x : S => x : S' - where code / S => S' - -- ``DIP n code``: Runs code protecting the ``n`` topmost elements of - the stack. In particular, ``DIP 0 code`` is equivalent to ``code`` - and ``DIP 1 code`` is equivalent to ``DIP code``. - -:: - - :: 'a{1} : ... : 'a{n} : 'A -> 'a{1} : ... : 'a{n} : 'B - iff code :: [ 'A -> 'B ] - - > DIP n code / x{1} : ... : x{n} : S => x{1} : ... : x{n} : S' - where code / S => S' - +- ``DIP n code``: Runs code protecting the ``n`` topmost elements of the stack. - ``EXEC``: Execute a function from the stack. - -:: - - :: 'a : lambda 'a 'b : 'C -> 'b : 'C - - > EXEC / a : f : S => r : S - where f / a : [] => r : [] - - ``APPLY``: Partially apply a tuplified function from the stack. - Values that are not both pushable and storable - (values of type ``operation``, ``contract _`` and ``big map _ _``) - cannot be captured by ``APPLY`` (cannot appear in ``'a``). - -:: - - :: 'a : lambda (pair 'a 'b) 'c : 'C -> lambda 'b 'c : 'C - - > APPLY / a : f : S => { PUSH 'a a ; PAIR ; f } : S Stack operations ~~~~~~~~~~~~~~~~ -- GitLab From bcbecb390c0055950618b521d8ba0a9cd2d057a5 Mon Sep 17 00:00:00 2001 From: Nicolas Ayache Date: Thu, 17 Nov 2022 09:59:59 +0100 Subject: [PATCH 2/2] Doc/Michelson: add links to the interactive reference. --- docs/alpha/michelson.rst | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/alpha/michelson.rst b/docs/alpha/michelson.rst index 6115560e7284..b3ce82b33291 100644 --- a/docs/alpha/michelson.rst +++ b/docs/alpha/michelson.rst @@ -511,16 +511,16 @@ Control structures A detailed description of the following instructions can be found in the `interactive Michelson reference manual `__. -- ``FAILWITH``: Explicitly abort the current program. -- ``{}``: Empty sequence. -- ``{ I ; C }``: Sequence. -- ``IF bt bf``: Conditional branching. -- ``LOOP body``: A generic loop. -- ``LOOP_LEFT body``: A loop with an accumulator. -- ``DIP code``: Runs code protecting the top element of the stack. -- ``DIP n code``: Runs code protecting the ``n`` topmost elements of the stack. -- ``EXEC``: Execute a function from the stack. -- ``APPLY``: Partially apply a tuplified function from the stack. +- ``FAILWITH``: Explicitly abort the current program (`documentation `__). +- ``{}``: Empty sequence (`documentation `__). +- ``{ I ; C }``: Sequence (`documentation `__). +- ``IF bt bf``: Conditional branching (`documentation `__). +- ``LOOP body``: A generic loop (`documentation `__). +- ``LOOP_LEFT body``: A loop with an accumulator (`documentation `__). +- ``DIP code``: Runs code protecting the top element of the stack (`documentation `__). +- ``DIP n code``: Runs code protecting the ``n`` topmost elements of the stack (`documentation `__). +- ``EXEC``: Execute a function from the stack (`documentation `__). +- ``APPLY``: Partially apply a tuplified function from the stack (`documentation `__). Stack operations ~~~~~~~~~~~~~~~~ -- GitLab