Compare commits

...

2 Commits

Author SHA1 Message Date
11d63c19f1 Updated README. 2025-11-22 10:36:05 -05:00
9b47ce1a44 Fixed call issues. 2025-11-22 10:31:40 -05:00
3 changed files with 16 additions and 25 deletions

View File

@@ -19,18 +19,6 @@ make release
./scl.out ./scl.out
``` ```
### For Development
```bash
git clone git@signorovitch.org:scl/scl --recurse-submodules && cd scl
make all test
./scl.out
```
If you wish to run tests, make sure to run `git clone --recurse-submodules` to
include the [Unity](https://github.com/ThrowTheSwitch/Unity) test framework.
*Note that tests are currently in poor use. I hope to amend this in the future.*
## Syntax ## Syntax
SCL's syntax will feel familiar to other functional programming languages. SCL's syntax will feel familiar to other functional programming languages.
@@ -41,10 +29,10 @@ SCL's syntax will feel familiar to other functional programming languages.
> f(x) x + 1 > f(x) x + 1
> f(1) > f(1)
= 2 = 2
> (\(x) 2 * x)(5) > \x, y 2 * x + y $ (2, 3)
= 10 = 7
> f(g) g(2) > f(g) g(2)
> f(\(x) 2 * x) > f(\x 2 * x)
= 4 = 4
``` ```

View File

@@ -185,11 +185,12 @@ AST* builtin_eq(size_t argc, AST** argv, Scope* parent) {
AST_TYPE_EXC, ast_exc_data_init("second was bad", second) AST_TYPE_EXC, ast_exc_data_init("second was bad", second)
); );
if (second->type != type) if (second->type != type) {
return ast_init( char* s = malloc(35);
AST_TYPE_EXC, sprintf(s, "first type %d, second type %d", type, second->type);
ast_exc_data_init("apples and oranges or something idk", NULL) // free(s);
); return ast_init(AST_TYPE_EXC, ast_exc_data_init(s, NULL));
}
// Later when I put together an anctual type system I'll have this // Later when I put together an anctual type system I'll have this
// delegated to each type. For now this works. // delegated to each type. For now this works.

View File

@@ -3,6 +3,7 @@
#include <string.h> #include <string.h>
#include "include/ast.h" #include "include/ast.h"
#include "include/ast_print.h"
#include "include/builtin.h" #include "include/builtin.h"
#include "include/exec.h" #include "include/exec.h"
#include "include/htab.h" #include "include/htab.h"
@@ -60,7 +61,9 @@ AST* exec_exp(AST* ast, Scope* parent) {
case AST_TYPE_LAMBDA: return ast; case AST_TYPE_LAMBDA: return ast;
case AST_TYPE_FORCE: return exec_force(ast, parent); case AST_TYPE_FORCE: return exec_force(ast, parent);
case AST_TYPE_PRESERVE: return exec_preserve(ast, parent); case AST_TYPE_PRESERVE: return exec_preserve(ast, parent);
default: printf("what\n"); exit(1); case AST_TYPE_EXC:
return ast_init(AST_TYPE_EXC, ast_exc_data_init("Can't.", ast));
default: printf("what : %d\n", ast->type); exit(1);
} }
} }
@@ -82,12 +85,13 @@ AST* exec_call(AST* ast, Scope* parent) {
AST* exp = exec_exp(calldata->exp, parent); AST* exp = exec_exp(calldata->exp, parent);
if (exp->scope) exp->scope->inherit = parent; Scope* scope = scope_init(parent);
exp->scope = scope;
switch (exp->type) { switch (exp->type) {
case AST_TYPE_BIF: case AST_TYPE_BIF:
return ((ASTBIFData)exp->data)( return ((ASTBIFData)exp->data)(
calldata->argc, calldata->argv, parent calldata->argc, calldata->argv, scope
); );
case AST_TYPE_LAMBDA: case AST_TYPE_LAMBDA:
return exec_lambda( return exec_lambda(
@@ -151,7 +155,6 @@ AST* exec_ref(AST* ast, Scope* parent) {
return ast_init(AST_TYPE_EXC, ast_exc_data_init(msg, NULL)); return ast_init(AST_TYPE_EXC, ast_exc_data_init(msg, NULL));
} }
// return exec_exp(found, ast->scope);
return found; return found;
} }
@@ -171,7 +174,6 @@ AST* exec_force(AST* ast, Scope* parent) {
AST* body = ((ASTForceData*)ast->data)->body; AST* body = ((ASTForceData*)ast->data)->body;
if (body->type == AST_TYPE_REF) { if (body->type == AST_TYPE_REF) {
printf("forcing var\n");
return exec_exp(exec_ref(body, parent), parent); return exec_exp(exec_ref(body, parent), parent);
} else return exec_exp(body, parent); } else return exec_exp(body, parent);
} }