Skip to content

Commit

Permalink
added default_macros_src
Browse files Browse the repository at this point in the history
  • Loading branch information
kev committed Jan 29, 2024
1 parent 5bf40c6 commit 7e002ec
Showing 1 changed file with 63 additions and 1 deletion.
64 changes: 63 additions & 1 deletion CLVMDotNet/src/Tools/Stages/Stage2/Defaults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,69 @@ namespace CLVMDotNet.Tools.Stages.Stage2;

public class Defaults
{
//DEFAULT_MACROS_SRC
public static List<string> DefaultMacrosSrc => new List<string>
{
@"
// we have to compile this externally, since it uses itself
// (defmacro defmacro (name params body)
// (qq (list (unquote name) (mod (unquote params) (unquote body))))
// )
(q . (""defmacro""
(c (q . ""list"")
(c (f 1)
(c (c (q . ""mod"")
(c (f (r 1))
(c (f (r (r 1)))
(q . ()))))
(q . ()))))))
",
@"
// (defmacro list ARGS
// ((c (mod args
// (defun compile-list
// (args)
// (if args
// (qq (c (unquote (f args))
// (unquote (compile-list (r args)))))
// ()))
// (compile-list args)
// )
// ARGS
// ))
// )
(q ""list""
(a (q #a (q #a 2 (c 2 (c 3 (q))))
(c (q #a (i 5
(q #c (q . 4)
(c 9 (c (a 2 (c 2 (c 13 (q))))
(q)))
)
(q 1))
1))
1))
",
@"
(defmacro function (BODY)
(qq (opt (com (q . (unquote BODY))
(qq (unquote (macros)))
(qq (unquote (symbols)))))))
",
@"
(defmacro if (A B C)
(qq (a
(i (unquote A)
(function (unquote B))
(function (unquote C)))
@)))
",
// / operator at the clvm layer is becoming deprecated and
// will be implemented using divmod.
@"
(defmacro / (A B) (qq (f (divmod (unquote A) (unquote B)))))
"
};


//DEFAULT_MACRO_LOOKUP
//build_default_macro_lookup
//default_macro_lookup
Expand Down

0 comments on commit 7e002ec

Please sign in to comment.