~tim/lydia

b438c021a93aac2624e8b36af9bf55f519a4a76f — Tim Morgan 2 years ago c1b0312
Rename to Lydia for simplicity
18 files changed, 25 insertions(+), 27 deletions(-)

M .gitignore
M Makefile
M README.md
R src/bin/{lidija.c => lydia.c}
M src/closure.c
M src/error.c
M src/eval.c
M src/funcs.c
M src/lib/base.c
M src/lib/list.c
M src/lib/logic.c
M src/lib/num.c
M src/lib/str.c
M src/lib/stream.c
R src/{lidija.h => lydia.h}
M src/parser.c
M src/parser.leg
M src/value.c
M .gitignore => .gitignore +1 -1
@@ 2,5 2,5 @@
*.so
Makefile
test/runner
bin/lidija
bin/lydia
ext

M Makefile => Makefile +5 -5
@@ 3,7 3,7 @@ CFLAGS=-I. -Wall
ALL = src/*.c src/lib/*.c src/ds/*.c
DEPS = -lgmp -Iext/include -Iext/include/ds ext/lib/libgc.so

build: bin/lidija
build: bin/lydia

leg: clean-leg src/parser.c



@@ 16,8 16,8 @@ src/parser.c:
clean:
	rm -f bin/* src/*.o src/*.so

bin/lidija: ext/lib/libgc.so
	${CC} src/bin/lidija.c -Isrc ${CFLAGS} ${ALL} ${DEPS} -o bin/lidija
bin/lydia: ext/lib/libgc.so
	${CC} src/bin/lydia.c -Isrc ${CFLAGS} ${ALL} ${DEPS} -o bin/lydia

ext/lib/libgc.so:
	mkdir -p ext


@@ 26,7 26,7 @@ ext/lib/libgc.so:
	cd ext/gc-7.6.4 && ./configure --prefix=`pwd`/../ --enable-redirect-malloc && make && make install

debug: ext/lib/libgc.so
	${CC} src/bin/lidija.c -Isrc ${CFLAGS} -g ${ALL} ${DEPS} -o bin/lidija
	${CC} src/bin/lydia.c -Isrc ${CFLAGS} -g ${ALL} ${DEPS} -o bin/lydia

cloc:
	cloc --not-match-f=parser\.c --force-lang=C,leg src


@@ 34,4 34,4 @@ cloc:
test: run-tests

run-tests:
	bin/lidija test/all.lid
	bin/lydia test/all.lid

M README.md => README.md +3 -5
@@ 1,8 1,6 @@
# Lidija
# Lydia

Pronounced same as "Lydia."

Lidija is an interpreted functional language that's taking shape as I learn, and **not meant for real work**.
Lydia is an interpreted functional language that's taking shape as I learn, and **not meant for real work**.

The syntax is very terse, as you can see below:



@@ 88,7 86,7 @@ The build task downloads and builds libgc -- if that fails, you may need to buil

## Usage

    bin/lidija scriptname [args]
    bin/lydia scriptname [args]

## Tests


R src/bin/lidija.c => src/bin/lydia.c +3 -3
@@ 1,8 1,8 @@
#include <argp.h>
#include "../lidija.h"
#include "../lydia.h"

const char *argp_program_version = "lidija " L_VERSION;
const char *argp_program_bug_address = "https://github.com/seven1m/lidija/issues";
const char *argp_program_version = "lydia " L_VERSION;
const char *argp_program_bug_address = "https://github.com/seven1m/lydia/issues";
static char doc[] = "Lidija -- a toy functional language";
static char args_doc[] = "script";


M src/closure.c => src/closure.c +1 -1
@@ 1,4 1,4 @@
#include "lidija.h"
#include "lydia.h"

// creates and initializes an empty closure
LClosure *l_closure_new(LNode *node) {

M src/error.c => src/error.c +1 -1
@@ 1,4 1,4 @@
#include "lidija.h"
#include "lydia.h"

void l_handle_error(LValue *error, LNode *node, LClosure *closure) {
  // TODO if error handling available, then do something nice

M src/eval.c => src/eval.c +1 -1
@@ 1,4 1,4 @@
#include "lidija.h"
#include "lydia.h"

LValue *l_eval_node(LNode *node, LClosure *closure) {
  LValue *value;

M src/funcs.c => src/funcs.c +1 -1
@@ 1,4 1,4 @@
#include "lidija.h"
#include "lydia.h"

LValue *l_eval_call_node(LNode *node, LValue *func, LClosure *closure) {


M src/lib/base.c => src/lib/base.c +1 -1
@@ 1,4 1,4 @@
#include "../lidija.h"
#include "../lydia.h"

LValue *l_func_add(LValue *args, LClosure *closure) {
  LValue *v1 = l_list_get(args, 0);

M src/lib/list.c => src/lib/list.c +1 -1
@@ 1,4 1,4 @@
#include "../lidija.h"
#include "../lydia.h"

LValue *l_list_get(LValue *list, long index) {
  if(index < list->core.list->length) {

M src/lib/logic.c => src/lib/logic.c +1 -1
@@ 1,4 1,4 @@
#include "../lidija.h"
#include "../lydia.h"

bool l_to_bool(LValue *cond) {
  return !(cond->type == L_NIL_TYPE ||

M src/lib/num.c => src/lib/num.c +1 -1
@@ 1,4 1,4 @@
#include "../lidija.h"
#include "../lydia.h"

LValue *l_func_num_add(LValue *args, LClosure *closure) {
  LValue *value = l_value_new(L_NUM_TYPE, closure);

M src/lib/str.c => src/lib/str.c +1 -1
@@ 1,4 1,4 @@
#include "../lidija.h"
#include "../lydia.h"

LValue *l_func_str(LValue *args, LClosure *closure) {
  LValue *value = l_value_new(L_STR_TYPE, closure);

M src/lib/stream.c => src/lib/stream.c +1 -1
@@ 1,4 1,4 @@
#include "../lidija.h"
#include "../lydia.h"

// TODO: LOTS of work to do here; we'll fake it for now


R src/lidija.h => src/lydia.h +0 -0

M src/parser.c => src/parser.c +1 -1
@@ 5,7 5,7 @@
#include <string.h>
#define YYRULECOUNT 35

#include "lidija.h"
#include "lydia.h"
int l_stackp = 0;
int l_line_no;
char *l_source_file;

M src/parser.leg => src/parser.leg +1 -1
@@ 1,5 1,5 @@
%{
#include "lidija.h"
#include "lydia.h"
int l_stackp = 0;
int l_line_no;
char *l_source_file;

M src/value.c => src/value.c +1 -1
@@ 1,4 1,4 @@
#include "lidija.h"
#include "lydia.h"

LValue *l_value_new(enum LNodeType type, LClosure *closure) {
  LValue *value = GC_MALLOC(sizeof(LValue));