1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-20 10:07:45 +03:00
Commit Graph

1679 Commits

Author SHA1 Message Date
Joel Martin
cc9dbd92e3 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
2016-10-14 22:42:56 -05:00
Joel Martin
30a3d8286f Basic: stepA basics. 2016-10-09 20:31:22 -05:00
Joel Martin
5e5ca0d438 Basic: step9 basics
- Change ER% to be -2 for no error, -1 for raw string error, and >=0
  as pointer to an error object.
2016-10-08 23:41:33 -05:00
Joel Martin
70f29a2b3c 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.
2016-10-06 22:22:57 -05:00
Joel Martin
60ef223c3c 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
2016-09-23 22:36:17 -05:00
Joel Martin
8be49ba8ef Basic: switch to python preprocessor.
- Adds ON GOTO, ON GOSUB support.
- Simplifies REM keep/drop to just yes/no
2016-09-22 22:14:08 -05:00
Joel Martin
9e8f521118 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.
2016-09-21 23:27:12 -05:00
Joel Martin
bf8d1f7d6c 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)
2016-09-20 21:11:46 -05:00
Joel Martin
85d70fb791 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.
2016-09-19 21:23:21 -05:00
Joel Martin
412e7348e3 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.
2016-09-17 23:03:30 -05:00
Joel Martin
01903266d2 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.
2016-09-16 01:38:44 -05:00
Joel Martin
4b84a23b07 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.
2016-09-16 01:00:58 -05:00
Joel Martin
60270667b0 Basic: move environment into normal memory. 2016-09-15 23:58:55 -05:00
Joel Martin
241d5d574a Basic: most of step4. 2016-09-11 21:36:15 -05:00
Joel Martin
0cb556e024 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
2016-09-11 00:11:55 -05:00
Joel Martin
b7b1787f83 Basic: step2 basics. Vectors and hash-maps.
Adjust step2 tests to keep values within 2 byte int range.
2016-09-10 22:13:27 -05:00
Joel Martin
11f94d2e74 Basic: step1 basics. 2016-09-04 20:42:50 -05:00
Joel Martin
47def37ef4 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.
2016-09-04 20:25:26 -05:00
Joel Martin
fa5af3ad92 Merge pull request #231 from iqbalansari/master
Update README to mention CLISP implementation
2016-08-29 12:47:06 -05:00
Iqbal Ansari
b0e083743e Add GNU CLISP to the list of implementations 2016-08-29 22:35:43 +05:30
Iqbal Ansari
68511d82dc Do not start MAL REPL if code is executed in Emacs (specially via SLIME) 2016-08-29 20:24:29 +05:30
Iqbal Ansari
798b5717f6 Add interop
- clisp-eval: allows executing Common Lisp
- define-builtin: allows defining builtin functions on the fly
2016-08-29 20:24:26 +05:30
Iqbal Ansari
5f6ad97006 Intern symbols in mal-user package while unwraping MAL values 2016-08-29 20:10:42 +05:30
Iqbal Ansari
32dda0de21 Print startup header when REPL starts 2016-08-29 16:37:11 +05:30
Iqbal Ansari
c1ad20675e Fix path of history file for readline 2016-08-29 16:37:00 +05:30
Joel Martin
8421dbf821 Merge pull request #230 from iqbalansari/clisp
Add MAL implementation in clisp
2016-08-28 16:01:15 -05:00
Iqbal Ansari
cfa139a7a1 Add make target to clean generated files 2016-08-28 23:33:49 +05:30
Iqbal Ansari
abb46bb21d Add readline integration support to the REPL 2016-08-28 23:33:35 +05:30
Iqbal Ansari
d65385bf2d Use only clisp specific features 2016-08-28 23:22:57 +05:30
Iqbal Ansari
3283e402d9 Compile clisp files before running
This step gives really good speedups, there still seem to be some
bottlenecks around evaluation which need attention
2016-08-28 22:26:35 +05:30
Iqbal Ansari
1d0a626d1f Move exports from types package to the top 2016-08-28 22:03:54 +05:30
Iqbal Ansari
d4fe5ef0a5 Use singleton values for nil, true and false 2016-08-28 21:46:37 +05:30
Iqbal Ansari
29cb42a450 Avoid creating unnecessary symbols for special froms in eval 2016-08-28 21:21:21 +05:30
Iqbal Ansari
3b97a1a78b Make sure dependencies are loaded only once 2016-08-28 20:43:15 +05:30
Iqbal Ansari
f6da27368c Coerce results of division to a non fractional value 2016-08-28 20:39:21 +05:30
Iqbal Ansari
20bd0392b9 Use find-env instead of get-env in is-macro-call
Apparently the earlier approach with all its error handling is slower
2016-08-28 20:09:20 +05:30
Iqbal Ansari
b6fce2eea0 Cleanup mal-value= 2016-08-28 19:57:09 +05:30
Iqbal Ansari
97c2c420d5 Store symbols as strings 2016-08-28 19:51:04 +05:30
Iqbal Ansari
b54ada313a Rename mal-type to mal-data 2016-08-28 17:58:06 +05:30
Iqbal Ansari
adaa0a0047 Use maphash to print hash-tables 2016-08-28 14:15:58 +05:30
Iqbal Ansari
f2539b37e5 Use compiled string and digit regular expressions 2016-08-28 11:19:45 +05:30
Iqbal Ansari
e929d5be8e Use compiled regex instead of raw ones 2016-08-28 10:45:58 +05:30
Iqbal Ansari
961c035bc3 Trying out defstruct instead of defclass for MAL types 2016-08-27 23:52:27 +05:30
Iqbal Ansari
098095fa3e Optimize tokenizer a bit
Avoid ignore-errors forms, apparently the ignore-errors form cost around
100 milliseconds in step 1 tests
2016-08-27 23:33:29 +05:30
Iqbal Ansari
844ac73813 Add travis config for clisp, also add stats target for clisp 2016-08-27 18:13:33 +05:30
Iqbal Ansari
c505538df9 Rename common_lisp to clisp 2016-08-27 18:13:33 +05:30
Iqbal Ansari
fd834e86a8 Make mal-errors catchable, self hosting is now complete
Remove implementation of print-object for MAL objects.
Also note the slowness of the implementation
2016-08-27 18:13:33 +05:30
Iqbal Ansari
5745b6ef3e Implement step A 2016-08-27 18:13:33 +05:30
Iqbal Ansari
381ff1a47a Implement all core functions required for step 9, completes step 9 2016-08-27 18:13:33 +05:30
Iqbal Ansari
efc3d24c32 Add nil?, true?, false? and symbol? 2016-08-27 18:13:33 +05:30