add license, copyright

This commit is contained in:
Sami Samhuri 2011-04-17 22:45:16 -07:00
parent 2d55d70770
commit c2f1607547
18 changed files with 196 additions and 26 deletions

19
LICENSE Normal file
View 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.

View file

@ -20,11 +20,11 @@ Hooray! It parses (reads), evaluates, and then prints things back.
Lake needs:
* booleans
* chars
* dotted lists
* functions
* flesh out eval, write apply
* dotted lists
* booleans
* chars
* primitives (especially define)
* define and friends
* branching
@ -41,3 +41,15 @@ Lake needs:
* 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.
Contributors
============
None of them want any credit.
License
=======
Copyright 2011 Sami Samhuri
MIT License, see included [LICENSE](blob/master/LICENSE) file

9
bool.c
View file

@ -1,3 +1,12 @@
/**
* bool.c
* Lake Scheme
*
* Copyright 2011 Sami Samhuri
* MIT License
*
*/
#include "bool.h"
#include "lake.h"
#include "sym.h"

9
bool.h
View file

@ -1,3 +1,12 @@
/**
* bool.h
* Lake Scheme
*
* Copyright 2011 Sami Samhuri
* MIT License
*
*/
#ifndef _LAKE_BOOL_H
#define _LAKE_BOOL_H 1

9
env.c
View file

@ -1,3 +1,12 @@
/**
* env.c
* Lake Scheme
*
* Copyright 2011 Sami Samhuri
* MIT License
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

9
env.h
View file

@ -1,3 +1,12 @@
/**
* env.h
* Lake Scheme
*
* Copyright 2011 Sami Samhuri
* MIT License
*
*/
#ifndef _LAKE_ENV_H
#define _LAKE_ENV_H 1

9
int.c
View file

@ -1,3 +1,12 @@
/**
* int.c
* Lake Scheme
*
* Copyright 2011 Sami Samhuri
* MIT License
*
*/
#include <stdio.h>
#include <stdlib.h>
#include "bool.h"

9
int.h
View file

@ -1,3 +1,12 @@
/**
* int.h
* Lake Scheme
*
* Copyright 2011 Sami Samhuri
* MIT License
*
*/
#ifndef _LAKE_INT_H
#define _LAKE_INT_H 1

22
lake.c
View file

@ -15,6 +15,7 @@
#include <string.h>
#include "env.h"
#include "lake.h"
#include "list.h"
#include "parse.h"
#include "string.h"
@ -92,27 +93,6 @@ void run_one_then_repl(int argc, char const *args[])
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 *s = NULL;

9
lake.h
View file

@ -1,3 +1,12 @@
/**
* lake.h
* Lake Scheme
*
* Copyright 2011 Sami Samhuri
* MIT License
*
*/
#ifndef _LAKE_LAKE_H
#define _LAKE_LAKE_H 1

36
list.c
View file

@ -1,3 +1,12 @@
/**
* list.c
* Lake Scheme
*
* Copyright 2011 Sami Samhuri
* MIT License
*
*/
#include <stdlib.h>
#include "int.h"
#include "lake.h"
@ -104,6 +113,29 @@ LakeSym *list_eq(LakeList *a, LakeList *b)
LakeStr *list_to_str(LakeList *list)
{
/* TODO */
return str_from_c("[TODO]");
char *s = list_repr(list);
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
View file

@ -1,3 +1,12 @@
/**
* list.h
* Lake Scheme
*
* Copyright 2011 Sami Samhuri
* MIT License
*
*/
#ifndef _LAKE_LIST_H
#define _LAKE_LIST_H 1
@ -16,5 +25,6 @@ LakeVal *list_get(LakeList *list, LakeInt *li);
LakeInt *list_cmp(LakeList *a, LakeList *b);
LakeSym *list_eq(LakeList *a, LakeList *b);
LakeStr *list_to_str(LakeList *list);
char *list_repr(LakeList *list);
#endif

View file

@ -1,3 +1,12 @@
/**
* parse.c
* Lake Scheme
*
* Copyright 2011 Sami Samhuri
* MIT License
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

View file

@ -1,3 +1,12 @@
/**
* parse.h
* Lake Scheme
*
* Copyright 2011 Sami Samhuri
* MIT License
*
*/
#ifndef _LAKE_PARSE_H
#define _LAKE_PARSE_H 1

View file

@ -1,3 +1,12 @@
/**
* string.c
* Lake Scheme
*
* Copyright 2011 Sami Samhuri
* MIT License
*
*/
#include <stdlib.h>
#include <string.h>
#include "int.h"

View file

@ -1,3 +1,12 @@
/**
* string.h
* Lake Scheme
*
* Copyright 2011 Sami Samhuri
* MIT License
*
*/
#ifndef _LAKE_STRING_H
#define _LAKE_STRING_H 1

9
sym.c
View file

@ -1,3 +1,12 @@
/**
* sym.c
* Lake Scheme
*
* Copyright 2011 Sami Samhuri
* MIT License
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

9
sym.h
View file

@ -1,3 +1,12 @@
/**
* sym.h
* Lake Scheme
*
* Copyright 2011 Sami Samhuri
* MIT License
*
*/
#ifndef _LAKE_SYM_H
#define _LAKE_SYM_H 1