Commit Graph

27 Commits

Author SHA1 Message Date
Christian Barthel ccfa109b06 literature, attchment material, general comments
i've added some literature that seems to
be interesting.   furthermore, i've updated
the comments about what's actually working.
2019-08-04 09:49:44 +02:00
Christian Barthel a6a66503b9 renamed flex file 2019-08-03 10:12:31 +02:00
Christian Barthel 354ea0bb6b remove left-over debugging code 2019-07-28 20:07:52 +02:00
Christian Barthel 874d7dba83 move file, cleanup sample session
- move tokenize.l file to llm.l (because
  the whole source is included in this file)
- cleanup sample, add sample.session
2019-07-28 19:56:21 +02:00
christian barthel 4b640bd275 function evaluation added
- `struct env` moved and `struct env` stores
  a pointer to an environment now as well.
  this is necessary to correctly evaluate
  functions at a later point in time.  consider
     (cons 1 2)
  which returns a function that binds arg1=1
  and arg2=2.  later, either arg1 or arg2
  will be accessed when doing
     (car (cons 1 2)) -> 1
     (cdr (cons 1 2)) -> 2
- debug_tval and debug_env has been added to
  show token or environments.
- add several reassure statements to verify
  the validity of the code.
- remove unnecessary 2nd environmental flag
  for eval().
  [ i thought this might be
    necessary to properly evaluate function
    calls but it turns out it's not
    necessary  ]
- add new function eval_lm().  this one
  should make the code structure cleaner
  and other custom forms have their own
  function as well.
  while there, remove debugging code as well
- remove eval_fn_name function (this one is
  actually not necessary)
- cleanup and implement eval_fn_call to
  call custom defined functions.  most of
  the former code has been removed and newly
  implemented.
  some examples that work now:

  (def cons (lm (x y) (lm (z) (if z x y))))
  (def cell (cons 1 2))
  (def cell2 (cons 3 cell))
  (cell2 t) -> 3
  (cell2 nil) -> #fn
  ((cell2 nil) t) -> 1
  (cell2 nil) nil) -> 2

  (def inc (lm (x) (add x 1)))
  (inc 1) ; -> 2
  (def inc2 (lm (x) (inc (inc x))))
  (inc2 2) -> 4

  [ more testing is still necessary ]
- BUGS section added
- small formatting updates here and there,
  whitespace removal etc.
2019-07-25 11:53:15 +02:00
Christian Barthel 293e6b80e4 comments, format, example code updated
format and more notes
2019-07-25 11:47:57 +02:00
Christian Barthel 712dcfc931 eval function calls, 2nd and improved attempt 2019-07-07 22:23:44 +02:00
Christian Barthel bc8cbe24e9 formatting, some tests 2019-07-06 20:25:47 +02:00
Christian Barthel ccd2bb723f cleanup, comments added
- add comments and underscores for symbol names
- remove printf
2019-07-05 09:08:02 +02:00
Christian Barthel 516c2f346d notes and examples 2019-07-05 09:07:16 +02:00
Christian Barthel e0bbc7f7cb repair string literals 2019-07-04 21:55:22 +02:00
Christian Barthel 02d3d783c9 allow lambda at first element of a list
previously, lambda wasn't evaluated if it was the first
element of a list.  it should be possible to evaluate
calls like
   ((lm (x) (add x 1)) 55) ->
now.
2019-07-04 21:32:49 +02:00
Christian Barthel 6b8812f467 bind args and create newenv, eval function calls
this commit adds the evaluation of user defined
functions.
2019-07-04 16:09:47 +02:00
Christian Barthel 4759a61a80 sample code 2019-07-04 16:09:13 +02:00
Christian Barthel 1e22fb868b reassure, evaluation of functions #1
- add reassure() function with useful error
  messages
- format code, with 65 cols max
- don't allow multiple definitions in one
	environment
- prepare eval of defined symbols
- prepare eval of lambda/functions
2019-07-04 10:19:37 +02:00
Christian Barthel 7ace1d6fe9 eval if statement, num2bool conversion 2019-07-02 23:10:55 +02:00
Christian Barthel 97a04bd1ce distinguish function calls from sym evaluation
prepare function call handling: till now, i've
just eval'ed new tokens but i think that i have
to distinguish a function call from a symbol
evaluation.
2019-06-30 23:10:17 +02:00
Christian Barthel e718421f17 lower than 2019-06-30 22:44:14 +02:00
Christian Barthel 68ecc91523 makefile added 2019-06-29 13:27:46 +02:00
Christian Barthel 7f362af841 add NAND, add boolean type, read form
- this commit adds the boolean type with the
	NAND operation (which is complete and other
	operations can be built by using NAND)
- read from now reads until an entire form
	has been entered.  line breaks, whitespace
	and tabs are allowed.
2019-06-29 13:20:05 +02:00
Christian Barthel 6f1ba0333f add inverse function 2019-06-29 12:30:06 +02:00
Christian Barthel 6440eeec77 split up eval code 2019-06-29 12:25:01 +02:00
Christian Barthel ca33a1096c parsing and environment infrastructure
. add env struct and parameter,
. add lookup() and append() functions
. add `q` and `add` in eval,
2019-06-29 12:06:43 +02:00
Christian Barthel 3ba49003f3 add first draft to eval a form 2019-06-28 21:12:12 +02:00
Christian Barthel 62cb03ebf0 parse init 2019-06-27 09:23:14 +02:00
Christian Barthel dab413018e work on structure 2019-06-26 23:00:48 +02:00
Christian Barthel 8b790839df tokenizer init 2019-06-26 22:21:36 +02:00