diff --git a/editor/special_forms.py b/editor/special_forms.py index 29d410d9..a4f0e384 100644 --- a/editor/special_forms.py +++ b/editor/special_forms.py @@ -1,6 +1,6 @@ from typing import List, Optional, Type -from datamodel import Expression, Symbol, Pair, SingletonTrue, SingletonFalse, Nil, Undefined, Promise, NilType +from datamodel import Expression, Symbol, Pair, SingletonTrue, SingletonFalse, Nil, Undefined, Promise, NilType, String from environment import global_attr from environment import special_form from evaluate_apply import Frame, evaluate, Callable, evaluate_all, Applicable @@ -438,6 +438,31 @@ def execute(self, operands: List[Expression], frame: Frame, gui_holder: Holder, raise LoadError(e) +@global_attr("load-all") +class LoadAll(Applicable): + def execute(self, operands: List[Expression], frame: Frame, gui_holder: Holder, eval_operands=True): + verify_exact_callable_length(self, 1, len(operands)) + if eval_operands: + operands = evaluate_all(operands, frame, gui_holder.expression.children[1:]) + if not isinstance(operands[0], String): + raise OperandDeduceError(f"Load expected a String, received {operands[0]}.") + if logger.fragile: + raise IrreversibleOperationError() + from os import listdir + from os.path import join + directory = operands[0].value + try: + targets = sorted(listdir(directory)) + targets = [join(directory, target) for target in targets if target.endswith(".scm")] + exprs = [make_list([Symbol("load"), make_list([Symbol("quote"), Symbol(x[:-4])])]) for x in targets] + equiv = make_list([Symbol("begin-noexcept")] + exprs) + gui_holder.expression.set_entries([equiv]) + gui_holder.apply() + return evaluate(equiv, frame, gui_holder.expression.children[0], True) + except Exception as e: + raise SchemeError(e) + + @special_form("begin-noexcept") class BeginNoExcept(Callable): def execute(self, operands: List[Expression], frame: Frame, gui_holder: Holder): diff --git a/release b/release new file mode 100644 index 00000000..38dbae21 --- /dev/null +++ b/release @@ -0,0 +1,7 @@ +"${3}" + +curl \ +--user "$1" \ +-d '{"tag_name":"'${2}'", "name":"'${3}'"}' \ +-H "Content-Type: application/json" \ +-X POST 'https://api.github.com/repos/Cal-CS-61A-Staff/scheme_editor/releases' diff --git a/strip_annotations b/strip_annotations deleted file mode 100644 index e12d354c..00000000 --- a/strip_annotations +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -cp -r ./editor ./compiled -for file in editor/*.py -do - py-backwards -i "$file" -t 3.5 -o compiled -d -done \ No newline at end of file diff --git a/transpile b/transpile new file mode 100644 index 00000000..f023f28d --- /dev/null +++ b/transpile @@ -0,0 +1,8 @@ +#!/bin/bash +mkdir -p ./compiled +cp -r ./editor ./compiled/editor +for file in editor/*.py +do + py-backwards -i "$file" -t 3.5 -o compiled/editor +done +zip -r editor.zip editor \ No newline at end of file