Joel Martin [Thu, 27 Oct 2016 03:29:09 +0000 (22:29 -0500)]
Basic: fix errors, reader, if form. Self-host 0-3
- Stop let binding eval on error. Also don't continue into EVAL if
error.
- if without a false position was freeing up too much when it
finished.
- fix reader so that it doesn't keep incrementing ref cnt of static
empty sequences.
Joel Martin [Thu, 27 Oct 2016 01:43:17 +0000 (20:43 -0500)]
Basic: use static empty sequences in reader.
- Add vector and hash-map empty static sequences in types
Joel Martin [Wed, 26 Oct 2016 06:26:05 +0000 (01:26 -0500)]
Basic: implement CALL in basicpp.py and use it.
- Add clean rule to Makefile and restructure deps.
Joel Martin [Tue, 25 Oct 2016 04:29:27 +0000 (23:29 -0500)]
Basic: Reduce GOSUB use. Partial self-host to step3
step4 runs out of space attempting to load the program. Step2 and
step3 run out of memory (stack exhaustion) for more complicated forms.
- Use GOTO with return label on our stack instead of GOSUB for:
- APPLY function in types.in.bas
- "apply", "map" and "swap!" core functions
- Implement DO TCO. Change EVAL_AST to detect if we are called from DO
and exit one element early.
- Remove GOSUB recursion from EQUAL_Q
- Inline PAIR_Q. Reduce REPLACE stack use.
- Remove one level of GOSUB/stack by calling REP with GOTO
- Simplify mal/step2_eval.mal to remove use of (or ) macro in
eval_ast.
- Fix ON GOTO/GOSUB line detection in basicpp
Joel Martin [Mon, 24 Oct 2016 03:18:08 +0000 (22:18 -0500)]
Basic: add read-file. Misc basicpp space savings.
- Add read-file which is similar to read-string but from a file name
rather than a string. This allows steps 0-2 to load although each
one eventuall crashes with out of memory after evaluating "123"
a few times.
- basicpp:
- Renumber the line numbers so they are ordinally increasing. This
saves 150 or so bytes because GOTO/GOSUB calls have smaller line
numbers.
- Shrink 'IF 123' -> 'IF123' for almost 300 byte savings.[:w
- Simplify PR_MEMORY_SUMMARY output. Save 75 bytes
- Add missing runtest.py change that allows basic tests to pass.
Joel Martin [Sat, 22 Oct 2016 21:11:46 +0000 (16:11 -0500)]
Basic: hashmap functions. Basic metadata (on funcs)
- Metadata support required expanding the type size (to 5 bits). This
also implies that ref cnt now only has 11 bits (2048).
- Added ^ reader macro (with-meta) which required some refactoring of
READ_MACRO to share code.
- Rename some more variables:
ZJ -> S
S% -> X%
ZR% -> Y%
ZM% -> Y
RE% -> D
This removes remaining % variables apart from the pre-allocated
arrays Z%, S% and X%.
Joel Martin [Sat, 15 Oct 2016 04:48:03 +0000 (23:48 -0500)]
Basic: smarter ALLOC. Keywords. Vector fixes.
- Modify ALLOC to take a type (rather than size) and take default
values to set for the 1-3 values/pointers. Let alloc do the
ownership taking of the referred values when appropriate.
- Add FORCE_SEQ_TYPE function to coerce sequence to given type. Fixes
apply and rest on vector. Simplifies concat.
- Use a double ON GOTO structure for calling the native functions in
DO_FUNCTION.
- Add some stub core functions.
- Move CHECK_FREE_LIST to debug.in.bas
- All changes together save over 1K
Joel Martin [Sat, 15 Oct 2016 03:42:56 +0000 (22:42 -0500)]
Basic: variable renaming. Save 2 kbytes.
Also, add variables.txt file with start of documenting meanings of
variables.
List of renamings/savings:
ZZ% -> S% : 131 bytes
ZL% -> X : 550 bytes
A% -> A : 192 bytes
E% -> E : 32 bytes
R% -> R : 381 bytes
AR% -> AR : 30 bytes
AY% -> AY : 71 bytes
AZ% -> AZ : 33 bytes
B% -> B : 47 bytes
AA% -> AA : 64 bytes
AB% -> AB : 25 bytes
F% -> F : 21 bytes
FF% -> FF : 14 bytes
ER% -> ER : 41 bytes
PR% -> PR : 7 bytes
T% -> T : 46 bytes
R0-9% -> R0-9 : 31 bytes
T0-9% -> T0-9 : 42 bytes
S1-4% -> S1-4 : 25 bytes
U0-9% -> U0-9 : 44 bytes
ZK% -> ZK : 10 bytes
ZI% -> ZI : 10 bytes
RC% -> RC : 16 bytes
K%/V% -> K/V : 21 bytes
SD% -> SD : 16 bytes
ZS$ -> S$ : 40 bytes
HM% -> H : 10 bytes
SZ% -> SZ : 39 bytes
LV% -> LV : 9 bytes
EO% -> O : 18 bytes
C% -> C : 4 bytes
P% -> P : 4 bytes
Joel Martin [Mon, 10 Oct 2016 01:31:22 +0000 (20:31 -0500)]
Basic: stepA basics.
Joel Martin [Sun, 9 Oct 2016 04:41:33 +0000 (23:41 -0500)]
Basic: step9 basics
- Change ER% to be -2 for no error, -1 for raw string error, and >=0
as pointer to an error object.
Joel Martin [Fri, 7 Oct 2016 03:22:57 +0000 (22:22 -0500)]
Basic: step8 basics. Fix def!, let*, concat, scalars.
- Move apply logic in swap! to APPLY function in types and use that
for macroexpand
- Abort def! if error before updating the environment
- let* wasn't properly saving A2% for the final eval. Also, the
environment release check should be against the top-level EVAL env,
not the root repl env.
- (concat (list) ...) was broken so fix it to ignore empty lists that
aren't in the trailing position.
- nil, false and true in the reader were always being returned as
references (with an ref cnt) but we have the assumption that
references (14) are not ref cnt'd and are always part of a compound
type so fix the reader to just return the interned addresses.
Joel Martin [Sat, 24 Sep 2016 03:36:17 +0000 (22:36 -0500)]
Basic: basicpp adds, other misc. Shaves 3031 bytes.
- basicpp.py:
- Fix "ON GOTO/GOSUB" label replacment
- Add combine line capability
- Change "THEN GOTO" to "THEN"
- Remove some spaces and unnecessary parens
- Restructure several places with multiple "GOTO/GOSUBs" statements
into fewer "ON GOTO/GOSUB" statements
Joel Martin [Fri, 23 Sep 2016 03:14:08 +0000 (22:14 -0500)]
Basic: switch to python preprocessor.
- Adds ON GOTO, ON GOSUB support.
- Simplifies REM keep/drop to just yes/no
Joel Martin [Thu, 22 Sep 2016 04:27:12 +0000 (23:27 -0500)]
Basic: step7 basics, reader macros. step1,3 tests.
Also:
- Add some step1 and step3 tests that were discovered during Basic
development.
- Move PR_MEMORY* to debug.in.bas
- Simplify Makefile deps
- Fix freeing in steps4-7 when error at deeper level
i.e. (prn (abc))
- add SLICE function to support concat implementation.
Joel Martin [Wed, 21 Sep 2016 02:11:46 +0000 (21:11 -0500)]
Basic: reduce memory usage by 614 bytes.
- combine some lines
- remove some unnecessary spaces and parens
- add string allocations to single routine in types
Also:
- remove blank lines in qb2cbm.sh output (does not save memory)
Joel Martin [Tue, 20 Sep 2016 02:23:21 +0000 (21:23 -0500)]
Basic: step6 basics and atoms. Fix strings.
Also:
- command lines arguments are implemented by creating a file
".args.mal" that contains a list of arguments and that is loaded by
the run script (load-file) into -*ARGS*-. The rest is put in *ARGV*
and the first element is pulled out and used as the script name.
- fix string reading/printing using new REPLACE function
- add RE function to skip printing and to get back evaluated value
(result must be freed by caller). Needed for step6 to get first
argument pointer for scripting.
- Sync earlier steps
- add cons, first, rest to support parsing the command line.
- eval is implemented as standard function in core.in.mal
- fix println bug (using PR_STR rather than PR_STR_SEQ)
- change sequence printing to save the initial sequence type on the
stack and use that for the ending sequence delimeter. This way
sequences of one type can still use the tail of sequences of
a different type but still be considered the initial type.
Joel Martin [Sun, 18 Sep 2016 04:03:30 +0000 (23:03 -0500)]
Basic: add step5, fix recursive/error memory issues.
- Add TCO recur to let*
- Release of all memory from recursive function and let* calls.
- Fix a number of cases of trying to release already freed memory.
- Print function in memory as 2 byte unit rather than two separate
memory locations.
Joel Martin [Fri, 16 Sep 2016 06:38:44 +0000 (01:38 -0500)]
Basic: fix readline to work on C64 (Vice).
Also, add cbmbasic console patch that makes it work more like the C64
where GET does not echo.
Joel Martin [Fri, 16 Sep 2016 06:00:58 +0000 (01:00 -0500)]
Basic: Add memory management. More step4.
Also:
- More/better detail in PR_MEMORY/PR_MEMORY_SUMMARY
- Fix *.prg image build (for running under Vice). Have to lower-case
everything since what C64/Vice shows as capitals are actually
lowercase.
Joel Martin [Fri, 16 Sep 2016 04:58:55 +0000 (23:58 -0500)]
Basic: move environment into normal memory.
Joel Martin [Mon, 12 Sep 2016 02:36:15 +0000 (21:36 -0500)]
Basic: most of step4.
Joel Martin [Sun, 11 Sep 2016 05:11:55 +0000 (00:11 -0500)]
Basic: add step3, vector/hash-map evaluation.
Also:
- qb2cbm.sh: Add KEEP_REM level variable to tweak which REM/comments
are emitted/skipped.
- fix printer issue with recursive sequences after evaluation (with
refeerences in them)
- add stats target
Joel Martin [Sun, 11 Sep 2016 03:13:27 +0000 (22:13 -0500)]
Basic: step2 basics. Vectors and hash-maps.
Adjust step2 tests to keep values within 2 byte int range.
Joel Martin [Mon, 5 Sep 2016 01:42:50 +0000 (20:42 -0500)]
Basic: step1 basics.
Joel Martin [Mon, 5 Sep 2016 01:23:56 +0000 (20:23 -0500)]
Basic (C64 v2): step0
This works with cbmbasic from https://github.com/mist64/cbmbasic. The
cbmbasic interpreter needs to be on the PATH.
The actually sources are *.in.bas which are "compiled" to *.bas using
the qb2cbm.sh. qb2cbm.sh translates from a QBasic-ish format to a line
numbered source with include files inlined (REM $INCLUDE: 'file.bas').
One additional advantage is that the *.in.bas versions can also be
indented and qb2cbm.sh will remove the indenting in the translated
code.
Joel Martin [Mon, 29 Aug 2016 17:47:06 +0000 (12:47 -0500)]
Merge pull request #231 from iqbalansari/master
Update README to mention CLISP implementation
Iqbal Ansari [Mon, 29 Aug 2016 14:44:52 +0000 (20:14 +0530)]
Add GNU CLISP to the list of implementations
Iqbal Ansari [Mon, 29 Aug 2016 14:44:15 +0000 (20:14 +0530)]
Do not start MAL REPL if code is executed in Emacs (specially via SLIME)
Iqbal Ansari [Mon, 29 Aug 2016 14:41:22 +0000 (20:11 +0530)]
Add interop
- clisp-eval: allows executing Common Lisp
- define-builtin: allows defining builtin functions on the fly
Iqbal Ansari [Mon, 29 Aug 2016 14:40:42 +0000 (20:10 +0530)]
Intern symbols in mal-user package while unwraping MAL values
Iqbal Ansari [Mon, 29 Aug 2016 11:07:11 +0000 (16:37 +0530)]
Print startup header when REPL starts
Iqbal Ansari [Mon, 29 Aug 2016 11:07:00 +0000 (16:37 +0530)]
Fix path of history file for readline
Joel Martin [Sun, 28 Aug 2016 21:01:15 +0000 (16:01 -0500)]
Merge pull request #230 from iqbalansari/clisp
Add MAL implementation in clisp
Iqbal Ansari [Sun, 28 Aug 2016 18:03:49 +0000 (23:33 +0530)]
Add make target to clean generated files
Iqbal Ansari [Sun, 28 Aug 2016 17:53:25 +0000 (23:23 +0530)]
Add readline integration support to the REPL
Iqbal Ansari [Sun, 28 Aug 2016 17:52:57 +0000 (23:22 +0530)]
Use only clisp specific features
Iqbal Ansari [Sun, 28 Aug 2016 16:40:14 +0000 (22:10 +0530)]
Compile clisp files before running
This step gives really good speedups, there still seem to be some
bottlenecks around evaluation which need attention
Iqbal Ansari [Sun, 28 Aug 2016 16:33:54 +0000 (22:03 +0530)]
Move exports from types package to the top
Iqbal Ansari [Sun, 28 Aug 2016 16:16:37 +0000 (21:46 +0530)]
Use singleton values for nil, true and false
Iqbal Ansari [Sun, 28 Aug 2016 15:34:01 +0000 (21:04 +0530)]
Avoid creating unnecessary symbols for special froms in eval
Iqbal Ansari [Sun, 28 Aug 2016 15:13:15 +0000 (20:43 +0530)]
Make sure dependencies are loaded only once
Iqbal Ansari [Sun, 28 Aug 2016 15:09:21 +0000 (20:39 +0530)]
Coerce results of division to a non fractional value
Iqbal Ansari [Sun, 28 Aug 2016 14:39:20 +0000 (20:09 +0530)]
Use find-env instead of get-env in is-macro-call
Apparently the earlier approach with all its error handling is slower
Iqbal Ansari [Sun, 28 Aug 2016 14:27:09 +0000 (19:57 +0530)]
Cleanup mal-value=
Iqbal Ansari [Sun, 28 Aug 2016 14:02:11 +0000 (19:32 +0530)]
Store symbols as strings
Iqbal Ansari [Sun, 28 Aug 2016 12:28:06 +0000 (17:58 +0530)]
Rename mal-type to mal-data
Iqbal Ansari [Sun, 28 Aug 2016 08:45:58 +0000 (14:15 +0530)]
Use maphash to print hash-tables
Iqbal Ansari [Sun, 28 Aug 2016 05:49:45 +0000 (11:19 +0530)]
Use compiled string and digit regular expressions
Iqbal Ansari [Sun, 28 Aug 2016 05:15:58 +0000 (10:45 +0530)]
Use compiled regex instead of raw ones
Iqbal Ansari [Sat, 27 Aug 2016 18:22:27 +0000 (23:52 +0530)]
Trying out defstruct instead of defclass for MAL types
Iqbal Ansari [Sat, 27 Aug 2016 18:03:29 +0000 (23:33 +0530)]
Optimize tokenizer a bit
Avoid ignore-errors forms, apparently the ignore-errors form cost around
100 milliseconds in step 1 tests
Iqbal Ansari [Sat, 27 Aug 2016 12:34:54 +0000 (18:04 +0530)]
Add travis config for clisp, also add stats target for clisp
Iqbal Ansari [Tue, 23 Aug 2016 17:50:03 +0000 (23:20 +0530)]
Rename common_lisp to clisp
Iqbal Ansari [Tue, 23 Aug 2016 17:28:46 +0000 (22:58 +0530)]
Make mal-errors catchable, self hosting is now complete
Remove implementation of print-object for MAL objects.
Also note the slowness of the implementation
Iqbal Ansari [Tue, 23 Aug 2016 17:04:00 +0000 (22:34 +0530)]
Implement step A
Iqbal Ansari [Mon, 22 Aug 2016 18:32:03 +0000 (00:02 +0530)]
Implement all core functions required for step 9, completes step 9
Iqbal Ansari [Mon, 22 Aug 2016 17:44:26 +0000 (23:14 +0530)]
Add nil?, true?, false? and symbol?
Iqbal Ansari [Mon, 22 Aug 2016 17:38:12 +0000 (23:08 +0530)]
Add 'apply' and 'map' core functions
Iqbal Ansari [Mon, 22 Aug 2016 17:21:50 +0000 (22:51 +0530)]
Add throw core function
Iqbal Ansari [Mon, 22 Aug 2016 17:21:06 +0000 (22:51 +0530)]
Add try* special form
Iqbal Ansari [Mon, 22 Aug 2016 17:19:11 +0000 (22:49 +0530)]
Introduce types mal-runtime-exception and mal-user-exception types
All the exceptions generated by runtime inherit from mal-user-exception
while user exceptions inherit from mal-user-exception
Iqbal Ansari [Sun, 21 Aug 2016 17:09:55 +0000 (22:39 +0530)]
Improve error handling
Iqbal Ansari [Sun, 21 Aug 2016 14:52:09 +0000 (20:22 +0530)]
Implement or and cond macros, completes step 8
Iqbal Ansari [Sun, 21 Aug 2016 14:17:26 +0000 (19:47 +0530)]
Implement nth, first and rest
Iqbal Ansari [Sun, 21 Aug 2016 14:09:45 +0000 (19:39 +0530)]
Add support for macros and macro expansion
Iqbal Ansari [Sun, 21 Aug 2016 09:09:01 +0000 (14:39 +0530)]
Implement quasiquote, completes step 7
Iqbal Ansari [Sun, 21 Aug 2016 08:08:40 +0000 (13:38 +0530)]
Add cons and concat
Iqbal Ansari [Sun, 21 Aug 2016 08:05:48 +0000 (13:35 +0530)]
Add unwrap value to convert from mal type to native types
Iqbal Ansari [Sun, 21 Aug 2016 05:59:59 +0000 (11:29 +0530)]
Eval keys of hash-map as well
Iqbal Ansari [Sat, 20 Aug 2016 18:42:58 +0000 (00:12 +0530)]
Add *ARGV*, completes step 6
Iqbal Ansari [Sat, 20 Aug 2016 18:39:18 +0000 (00:09 +0530)]
Add all required atom functions
Iqbal Ansari [Sat, 20 Aug 2016 18:24:37 +0000 (23:54 +0530)]
Fix reading of quotes
Iqbal Ansari [Sat, 20 Aug 2016 18:24:28 +0000 (23:54 +0530)]
Add atom type
Iqbal Ansari [Sat, 20 Aug 2016 18:24:16 +0000 (23:54 +0530)]
Add load-file function
Iqbal Ansari [Sat, 20 Aug 2016 17:42:04 +0000 (23:12 +0530)]
Add `eval` builtin
Iqbal Ansari [Sat, 20 Aug 2016 16:21:32 +0000 (21:51 +0530)]
Handle non-mal datatypes in mal-value=
Iqbal Ansari [Sat, 20 Aug 2016 08:10:26 +0000 (13:40 +0530)]
Implement slurp and read-string
Iqbal Ansari [Sat, 20 Aug 2016 07:33:16 +0000 (13:03 +0530)]
Implement tail calls for functions, completes step 5
Iqbal Ansari [Sat, 20 Aug 2016 07:08:46 +0000 (12:38 +0530)]
Implement tail calls for 'let*', 'if' and 'do'
Iqbal Ansari [Fri, 19 Aug 2016 11:41:21 +0000 (17:11 +0530)]
Implement print_readably, completes step 4
Iqbal Ansari [Thu, 18 Aug 2016 19:00:14 +0000 (00:30 +0530)]
Implement equality between vectors and list
Iqbal Ansari [Thu, 18 Aug 2016 19:00:02 +0000 (00:30 +0530)]
Implement `not` in MAL
Iqbal Ansari [Thu, 18 Aug 2016 18:59:27 +0000 (00:29 +0530)]
Treat nil as a list in list?
Iqbal Ansari [Thu, 18 Aug 2016 18:58:34 +0000 (00:28 +0530)]
Add support for variadic arguments
Iqbal Ansari [Thu, 18 Aug 2016 16:42:01 +0000 (22:12 +0530)]
Make sure the REPL does not crash on unknown errors
Iqbal Ansari [Thu, 18 Aug 2016 16:38:57 +0000 (22:08 +0530)]
Fix wrapping of Common Lisp value into MAL values
1) Since nil and t are symbols also, we need the specific clauses
i.e. null and boolean before symbol clause
2) Since nil stands for both an empty list as well as false in common
lisp as opposed to MAL where these are distinct values, we need to use
explicit flag while wrapping them
Iqbal Ansari [Thu, 18 Aug 2016 16:38:14 +0000 (22:08 +0530)]
Teach mal-value= to compare list and hash-maps
Iqbal Ansari [Thu, 18 Aug 2016 15:28:14 +0000 (20:58 +0530)]
Use symbol name while comparing mal-symbols
Iqbal Ansari [Thu, 18 Aug 2016 13:28:58 +0000 (18:58 +0530)]
Initial attempt at adding core functions required for step 4
Iqbal Ansari [Wed, 17 Aug 2016 18:32:43 +0000 (00:02 +0530)]
Implement fn*, do and let*
Iqbal Ansari [Wed, 17 Aug 2016 18:31:59 +0000 (00:01 +0530)]
Allow specifying initial set of bindings while creating new environment
Iqbal Ansari [Wed, 17 Aug 2016 18:31:44 +0000 (00:01 +0530)]
Add support for printing functions
Iqbal Ansari [Wed, 17 Aug 2016 16:49:03 +0000 (22:19 +0530)]
Implement step 3 (environment)
Iqbal Ansari [Wed, 17 Aug 2016 10:47:27 +0000 (16:17 +0530)]
Add mal-environment class
Iqbal Ansari [Wed, 17 Aug 2016 10:38:46 +0000 (16:08 +0530)]
Update apply-unwrapped-values to also wrap the result into a mal type
Iqbal Ansari [Wed, 17 Aug 2016 03:23:12 +0000 (08:53 +0530)]
Complete implmentation of step 2 (eval)
Iqbal Ansari [Sat, 20 Aug 2016 16:45:22 +0000 (22:15 +0530)]
Add printer for built-in functions
Iqbal Ansari [Wed, 17 Aug 2016 02:58:59 +0000 (08:28 +0530)]
Export predicates for checking MAL types from types package
Iqbal Ansari [Wed, 17 Aug 2016 02:58:43 +0000 (08:28 +0530)]
Teach MAL about number signs
Iqbal Ansari [Wed, 17 Aug 2016 02:16:37 +0000 (07:46 +0530)]
Change the way meta is handled
This might require some more modifications in future