mirror of
https://github.com/samsonjs/lake.git
synced 2026-04-27 14:57:43 +00:00
add license, copyright
This commit is contained in:
parent
2d55d70770
commit
c2f1607547
18 changed files with 196 additions and 26 deletions
19
LICENSE
Normal file
19
LICENSE
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
Copyright (c) 2011 Sami Samhuri - sami.samhuri@gmail.com
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
18
Readme.md
18
Readme.md
|
|
@ -20,11 +20,11 @@ Hooray! It parses (reads), evaluates, and then prints things back.
|
||||||
|
|
||||||
Lake needs:
|
Lake needs:
|
||||||
|
|
||||||
* booleans
|
* dotted lists
|
||||||
* chars
|
|
||||||
* functions
|
* functions
|
||||||
* flesh out eval, write apply
|
* flesh out eval, write apply
|
||||||
* dotted lists
|
* booleans
|
||||||
|
* chars
|
||||||
* primitives (especially define)
|
* primitives (especially define)
|
||||||
* define and friends
|
* define and friends
|
||||||
* branching
|
* branching
|
||||||
|
|
@ -41,3 +41,15 @@ Lake needs:
|
||||||
* sugar such as '... -> (quote ...)
|
* sugar such as '... -> (quote ...)
|
||||||
|
|
||||||
I don't think I'll need any other numeric types, but they are easy to implement anyway when performance is no concern and they're all boxed.
|
I don't think I'll need any other numeric types, but they are easy to implement anyway when performance is no concern and they're all boxed.
|
||||||
|
|
||||||
|
Contributors
|
||||||
|
============
|
||||||
|
|
||||||
|
None of them want any credit.
|
||||||
|
|
||||||
|
License
|
||||||
|
=======
|
||||||
|
|
||||||
|
Copyright 2011 Sami Samhuri
|
||||||
|
|
||||||
|
MIT License, see included [LICENSE](blob/master/LICENSE) file
|
||||||
9
bool.c
9
bool.c
|
|
@ -1,3 +1,12 @@
|
||||||
|
/**
|
||||||
|
* bool.c
|
||||||
|
* Lake Scheme
|
||||||
|
*
|
||||||
|
* Copyright 2011 Sami Samhuri
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#include "bool.h"
|
#include "bool.h"
|
||||||
#include "lake.h"
|
#include "lake.h"
|
||||||
#include "sym.h"
|
#include "sym.h"
|
||||||
|
|
|
||||||
9
bool.h
9
bool.h
|
|
@ -1,3 +1,12 @@
|
||||||
|
/**
|
||||||
|
* bool.h
|
||||||
|
* Lake Scheme
|
||||||
|
*
|
||||||
|
* Copyright 2011 Sami Samhuri
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef _LAKE_BOOL_H
|
#ifndef _LAKE_BOOL_H
|
||||||
#define _LAKE_BOOL_H 1
|
#define _LAKE_BOOL_H 1
|
||||||
|
|
||||||
|
|
|
||||||
9
env.c
9
env.c
|
|
@ -1,3 +1,12 @@
|
||||||
|
/**
|
||||||
|
* env.c
|
||||||
|
* Lake Scheme
|
||||||
|
*
|
||||||
|
* Copyright 2011 Sami Samhuri
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
|
||||||
9
env.h
9
env.h
|
|
@ -1,3 +1,12 @@
|
||||||
|
/**
|
||||||
|
* env.h
|
||||||
|
* Lake Scheme
|
||||||
|
*
|
||||||
|
* Copyright 2011 Sami Samhuri
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef _LAKE_ENV_H
|
#ifndef _LAKE_ENV_H
|
||||||
#define _LAKE_ENV_H 1
|
#define _LAKE_ENV_H 1
|
||||||
|
|
||||||
|
|
|
||||||
9
int.c
9
int.c
|
|
@ -1,3 +1,12 @@
|
||||||
|
/**
|
||||||
|
* int.c
|
||||||
|
* Lake Scheme
|
||||||
|
*
|
||||||
|
* Copyright 2011 Sami Samhuri
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "bool.h"
|
#include "bool.h"
|
||||||
|
|
|
||||||
9
int.h
9
int.h
|
|
@ -1,3 +1,12 @@
|
||||||
|
/**
|
||||||
|
* int.h
|
||||||
|
* Lake Scheme
|
||||||
|
*
|
||||||
|
* Copyright 2011 Sami Samhuri
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef _LAKE_INT_H
|
#ifndef _LAKE_INT_H
|
||||||
#define _LAKE_INT_H 1
|
#define _LAKE_INT_H 1
|
||||||
|
|
||||||
|
|
|
||||||
22
lake.c
22
lake.c
|
|
@ -15,6 +15,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "env.h"
|
#include "env.h"
|
||||||
#include "lake.h"
|
#include "lake.h"
|
||||||
|
#include "list.h"
|
||||||
#include "parse.h"
|
#include "parse.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
|
||||||
|
|
@ -92,27 +93,6 @@ void run_one_then_repl(int argc, char const *args[])
|
||||||
run_repl_with_env(env);
|
run_repl_with_env(env);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *list_repr(LakeList *list)
|
|
||||||
{
|
|
||||||
char s[1024];
|
|
||||||
size_t n = 0;
|
|
||||||
s[n++] = '(';
|
|
||||||
int i;
|
|
||||||
char *s2;
|
|
||||||
size_t len;
|
|
||||||
for (i = 0; i < LIST_N(list); ++i) {
|
|
||||||
s2 = repr(LIST_VAL(list, i));
|
|
||||||
len = strlen(s2);
|
|
||||||
memcpy(s + n, s2, len);
|
|
||||||
n += len;
|
|
||||||
free(s2);
|
|
||||||
if (i != LIST_N(list) - 1) s[n++] = ' ';
|
|
||||||
}
|
|
||||||
s[n++] = ')';
|
|
||||||
s[n] = 0;
|
|
||||||
return strdup(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
char *repr(LakeVal *expr)
|
char *repr(LakeVal *expr)
|
||||||
{
|
{
|
||||||
char *s = NULL;
|
char *s = NULL;
|
||||||
|
|
|
||||||
9
lake.h
9
lake.h
|
|
@ -1,3 +1,12 @@
|
||||||
|
/**
|
||||||
|
* lake.h
|
||||||
|
* Lake Scheme
|
||||||
|
*
|
||||||
|
* Copyright 2011 Sami Samhuri
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef _LAKE_LAKE_H
|
#ifndef _LAKE_LAKE_H
|
||||||
#define _LAKE_LAKE_H 1
|
#define _LAKE_LAKE_H 1
|
||||||
|
|
||||||
|
|
|
||||||
36
list.c
36
list.c
|
|
@ -1,3 +1,12 @@
|
||||||
|
/**
|
||||||
|
* list.c
|
||||||
|
* Lake Scheme
|
||||||
|
*
|
||||||
|
* Copyright 2011 Sami Samhuri
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "int.h"
|
#include "int.h"
|
||||||
#include "lake.h"
|
#include "lake.h"
|
||||||
|
|
@ -104,6 +113,29 @@ LakeSym *list_eq(LakeList *a, LakeList *b)
|
||||||
|
|
||||||
LakeStr *list_to_str(LakeList *list)
|
LakeStr *list_to_str(LakeList *list)
|
||||||
{
|
{
|
||||||
/* TODO */
|
char *s = list_repr(list);
|
||||||
return str_from_c("[TODO]");
|
LakeStr *str = str_from_c(s);
|
||||||
|
free(s);
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *list_repr(LakeList *list)
|
||||||
|
{
|
||||||
|
char s[1024];
|
||||||
|
size_t n = 0;
|
||||||
|
s[n++] = '(';
|
||||||
|
int i;
|
||||||
|
char *s2;
|
||||||
|
size_t len;
|
||||||
|
for (i = 0; i < LIST_N(list); ++i) {
|
||||||
|
s2 = repr(LIST_VAL(list, i));
|
||||||
|
len = strlen(s2);
|
||||||
|
memcpy(s + n, s2, len);
|
||||||
|
n += len;
|
||||||
|
free(s2);
|
||||||
|
if (i != LIST_N(list) - 1) s[n++] = ' ';
|
||||||
|
}
|
||||||
|
s[n++] = ')';
|
||||||
|
s[n] = 0;
|
||||||
|
return strdup(s);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
10
list.h
10
list.h
|
|
@ -1,3 +1,12 @@
|
||||||
|
/**
|
||||||
|
* list.h
|
||||||
|
* Lake Scheme
|
||||||
|
*
|
||||||
|
* Copyright 2011 Sami Samhuri
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef _LAKE_LIST_H
|
#ifndef _LAKE_LIST_H
|
||||||
#define _LAKE_LIST_H 1
|
#define _LAKE_LIST_H 1
|
||||||
|
|
||||||
|
|
@ -16,5 +25,6 @@ LakeVal *list_get(LakeList *list, LakeInt *li);
|
||||||
LakeInt *list_cmp(LakeList *a, LakeList *b);
|
LakeInt *list_cmp(LakeList *a, LakeList *b);
|
||||||
LakeSym *list_eq(LakeList *a, LakeList *b);
|
LakeSym *list_eq(LakeList *a, LakeList *b);
|
||||||
LakeStr *list_to_str(LakeList *list);
|
LakeStr *list_to_str(LakeList *list);
|
||||||
|
char *list_repr(LakeList *list);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
9
parse.c
9
parse.c
|
|
@ -1,3 +1,12 @@
|
||||||
|
/**
|
||||||
|
* parse.c
|
||||||
|
* Lake Scheme
|
||||||
|
*
|
||||||
|
* Copyright 2011 Sami Samhuri
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
|
||||||
9
parse.h
9
parse.h
|
|
@ -1,3 +1,12 @@
|
||||||
|
/**
|
||||||
|
* parse.h
|
||||||
|
* Lake Scheme
|
||||||
|
*
|
||||||
|
* Copyright 2011 Sami Samhuri
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef _LAKE_PARSE_H
|
#ifndef _LAKE_PARSE_H
|
||||||
#define _LAKE_PARSE_H 1
|
#define _LAKE_PARSE_H 1
|
||||||
|
|
||||||
|
|
|
||||||
9
string.c
9
string.c
|
|
@ -1,3 +1,12 @@
|
||||||
|
/**
|
||||||
|
* string.c
|
||||||
|
* Lake Scheme
|
||||||
|
*
|
||||||
|
* Copyright 2011 Sami Samhuri
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "int.h"
|
#include "int.h"
|
||||||
|
|
|
||||||
9
string.h
9
string.h
|
|
@ -1,3 +1,12 @@
|
||||||
|
/**
|
||||||
|
* string.h
|
||||||
|
* Lake Scheme
|
||||||
|
*
|
||||||
|
* Copyright 2011 Sami Samhuri
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef _LAKE_STRING_H
|
#ifndef _LAKE_STRING_H
|
||||||
#define _LAKE_STRING_H 1
|
#define _LAKE_STRING_H 1
|
||||||
|
|
||||||
|
|
|
||||||
9
sym.c
9
sym.c
|
|
@ -1,3 +1,12 @@
|
||||||
|
/**
|
||||||
|
* sym.c
|
||||||
|
* Lake Scheme
|
||||||
|
*
|
||||||
|
* Copyright 2011 Sami Samhuri
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
|
||||||
9
sym.h
9
sym.h
|
|
@ -1,3 +1,12 @@
|
||||||
|
/**
|
||||||
|
* sym.h
|
||||||
|
* Lake Scheme
|
||||||
|
*
|
||||||
|
* Copyright 2011 Sami Samhuri
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef _LAKE_SYM_H
|
#ifndef _LAKE_SYM_H
|
||||||
#define _LAKE_SYM_H 1
|
#define _LAKE_SYM_H 1
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue