sasagawa888 / eisl Goto Github PK
View Code? Open in Web Editor NEWISLisp interpreter/compiler
License: Other
ISLisp interpreter/compiler
License: Other
(defun fib* (n)
(cond ((= n 1.0) 1.0)
((= n 2.0) 1.0)
(t (+ (fib* (- n 1.0)) (fib* (- n 2.0))))))
type-function
((FIB* ()))
These should be usable for benchmarking and measure wallclock time, for example with gettimeofday
or clock_gettime
.
When forget right hand double quotation '"' , segmentation fault error.
still some non conformity in controle.lsp.
On REPL (Linux version) , shift+ ↑ ↓ error
Code:
(defun tokenize (input)
(let ((in (create-string-input-stream input))
(char nil))
(while (setq char (preview-char in nil))
(read-char in nil))
(close in)))
(tokenize "123")
(format (standard-output) "This won't be printed~%")
I expect something to be printed, but nothing is printed at all, as if it skips evaluation of everything after the tokenize
call.
; ; eisl -s bug.lsp
; ;
I uploaded the document. I'm not good at English. I would be grateful if anyone could correct the English.
(defglobal q00 #2a((5 3 0 0 7 0 0 0 0)
(6 0 0 1 9 5 0 0 0)
(0 9 8 0 0 0 0 6 0)
(8 0 0 0 6 0 0 0 3)
(4 0 0 8 0 3 0 0 1)
(7 0 0 0 2 0 0 0 6)
(0 6 0 0 0 0 2 8 0)
(0 0 0 4 1 9 0 0 5)
(0 0 0 0 8 0 0 7 9)))
(aref q00 1 0)
0 ->6
(aref q00 1 1)
0 ->9
(aref q00 1 2)
1 ->0
(aref q00 1 3)
9 ->1
read-char
accepts the optional arguments eos-error-p
and eos-value
in cases where you want to handle EOF differently, but seems to ignore them:
(let* ((input "1 + 1")
(in (create-string-input-stream input))
(char nil))
(while (setq char (preview-char in nil))
(format (standard-output) "Char: ~S~%" char)
(read-char in nil))
(close in))
Output:
; ; echo -ne "foo\nbar\nbaz" | eisl -s run.lsp
Char: #\\1
Char: #\\+
Char: #\\1
22around here line=76 column=0
Illegal input at read NIL
debug mode ?(help)
>>*** stack smashing detected ***: terminated
zsh: done echo -ne "foo\nbar\nbaz" |
zsh: abort (core dumped) eisl -s run.lsp
Here's how a typical part of an Archlinux PKGBUILD looks like:
cd eisl
make PREFIX=/usr DESTDIR="$pkgdir" install
Instead I had to resort to the following as only DEST
is supported:
cd eisl
install -Dm755 "$srcdir"/eisl/eisl "$pkgdir"/usr/bin/eisl
install -Dm755 "$srcdir"/eisl/edlis "$pkgdir"/usr/bin/edlis
DESTDIR
is the root directory the files get copied to, PREFIX
is the directory in that root (defaulting to /usr/local
, set to /usr
by distributions) and the makefile
would create extra paths in there as necessary.
freeze when GC starts. e.g. 10queens
function.c:295:13: error: expected declaration specifiers or '...' before numeric constant
295 | init_f0(0,(tfunc)checkgbc);
| ^
function.c:295:15: error: expected declaration specifiers or '...' before '(' token
295 | init_f0(0,(tfunc)checkgbc);
| ^
function.c:296:13: error: expected declaration specifiers or '...' before numeric constant
296 | init_f0(1,(tfunc)gbc);
| ^
function.c:296:15: error: expected declaration specifiers or '...' before '(' token
296 | init_f0(1,(tfunc)gbc);
| ^
function.c:297:13: error: expected declaration specifiers or '...' before numeric constant
297 | init_f0(2,(tfunc)freshcell);
| ^
On Debian GCC 6.3, EISL can compile lisp code. But EISL can't load object file. Segmentation Fault.
The HOME
and END
keys on the keyboard do not navigate the cursor as expected. Control+Arrow keys and Alt+Arrow do not navigate the cursor as expected.
I am a long-time Linux user, and I expect the libreadline
keybindings to work in most REPLs, which are similar to Emacs keybindings. It would be a good idea to provide these keybindings as a feature.
It would be nice if you could enable these keybindings. Do you have plans to make the keybindings configurable, similar to what Emacs does? I think this would be a nice feature.
(I am on Ubuntu Linux 19.10, compiled with GCC 9.2.1)
(equal 2 2.0)
T
(eql 2 2.0)
T
Result shoud be NIL
Expt function does not match ISLisp verification tests in Raspberry Pi.
Here's a full program this time:
(defun println (fmt &rest args)
(apply #'format (standard-output) (string-append fmt "~%") args))
(defun whitespacep (c) (or (char= c #\space) (char= c #\newline)))
(defun digitp (c) (and (char>= c #\0) (char<= c #\9)))
(defun specialp (c) (member c '(#\+ #\- #\* #\/ #\( #\))))
(defun list-to-string (chars)
(let ((string (create-string (length chars)))
(i 0))
(while chars
(setf (aref string i) (car chars))
(setq i (+ i 1))
(setq chars (cdr chars)))
string))
(defun read-whitespace (in)
(let ((char nil))
(while (and (setq char (preview-char in nil))
(whitespacep char))
(read-char in))))
(defun read-number (in)
(let ((chars nil)
(char nil))
(while (and (setq char (preview-char in nil))
(digitp char))
(setq chars (cons (read-char in) chars)))
(list-to-string (nreverse chars))))
(defun tokenize (input)
(let ((in (create-string-input-stream input))
(tokens nil)
(char nil))
(while (setq char (preview-char in nil))
(cond
((whitespacep char)
(read-whitespace in))
((digitp char)
(setq tokens (cons (read-number in) tokens)))
((specialp char)
(setq tokens (cons (create-string 1 (read-char in)) tokens)))
(t (close in) (error "unknown char ~S" char))))
(close in)
(nreverse tokens)))
(println "Tokens: ~S" (tokenize "1 * (2 * 3) + 4"))
Output:
; ; eisl -s bug.lsp
enter M&S-GC free=899
zsh: segmentation fault (core dumped) eisl -s bug.lsp
Backtrace:
Reading symbols from /usr/bin/eisl...
[New LWP 284241]
Core was generated by `eisl -s bug.lsp'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x0000558eb5a59325 in markcell (addr=11751087) at gbc.c:53
53 void markcell(int addr){
(gdb) bt
#0 0x0000558eb5a59325 in markcell (addr=11751087) at gbc.c:53
#1 0x0000558eb5a593a7 in markcell (addr=<optimized out>) at gbc.c:108
#2 0x0000558eb5a593b6 in markcell (addr=<optimized out>) at gbc.c:109
#3 0x0000558eb5a593b6 in markcell (addr=<optimized out>) at gbc.c:109
#4 0x0000558eb5a593b6 in markcell (addr=<optimized out>) at gbc.c:109
#5 0x0000558eb5a593b6 in markcell (addr=<optimized out>) at gbc.c:109
[...]
Line 1 from the backtrace output is repeated with no end in sight.
edit: If I add (gbc 'copy)
at the beginning of the program, there's slightly different output:
; ; eisl -s bug.lsp
enter COPY-GC free=898
exit COPY-GC free=6791049
zsh: segmentation fault (core dumped) eisl -s bug.lsp
Backtrace:
Reading symbols from /usr/bin/eisl...
[New LWP 286642]
Core was generated by `eisl -s bug.lsp'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00005633074c3627 in readc () at main.c:391
391 c = GET_NAME(input_stream)[GET_CDR(input_stream)];
(gdb) bt
#0 0x00005633074c3627 in readc () at main.c:391
#1 0x00005633074cb3f1 in f_read_char (arglist=<optimized out>) at function.c:1751
#2 0x00005633074c74bf in evlis (addr=2011) at main.c:1534
#3 evlis (addr=2011) at main.c:1524
#4 0x00005633074c6cad in eval (addr=<optimized out>) at main.c:1354
#5 0x00005633074d5276 in f_setq (arglist=2014) at syntax.c:316
#6 0x00005633074d7ad0 in f_progn (arglist=2016) at syntax.c:922
#7 f_while (arglist=<optimized out>) at syntax.c:635
#8 0x00005633074d45a2 in f_let (arglist=<optimized out>) at syntax.c:166
#9 0x00005633074c6fcf in apply (func=2002, args=12999087) at main.c:1399
#10 0x00005633074c6ccc in eval (addr=<optimized out>) at main.c:1357
#11 0x00005633074c74bf in evlis (addr=2085) at main.c:1534
#12 evlis (addr=2085) at main.c:1524
#13 0x00005633074c6cad in eval (addr=<optimized out>) at main.c:1354
#14 0x00005633074d5276 in f_setq (arglist=2088) at syntax.c:316
#15 0x00005633074d8379 in f_progn (arglist=2090) at syntax.c:922
#16 f_cond (arglist=<optimized out>) at syntax.c:624
#17 0x00005633074d7ad0 in f_progn (arglist=2103) at syntax.c:922
#18 f_while (arglist=<optimized out>) at syntax.c:635
#19 0x00005633074d45a2 in f_let (arglist=<optimized out>) at syntax.c:166
#20 0x00005633074c6fcf in apply (func=2048, args=6000285) at main.c:1399
#21 0x00005633074c6ccc in eval (addr=<optimized out>) at main.c:1357
#22 0x00005633074c74bf in evlis (addr=6000282) at main.c:1534
#23 evlis (addr=6000282) at main.c:1524
#24 0x00005633074c74e5 in evlis (addr=6000283) at main.c:1536
#25 evlis (addr=6000283) at main.c:1524
#26 0x00005633074c6d0f in eval (addr=<optimized out>) at main.c:1346
#27 0x00005633074d1678 in f_load (arglist=<optimized out>) at function.c:2022
#28 0x00005633074c333d in main (argc=3, argv=0x7ffde5f9e408) at main.c:283
Error checking in syntax is incomplete
-c
is a start, but not sufficient. It still prints a version number and enters a REPL instead of quitting (and quitting with (quit)
prints text). For example -s
could be introduced.
If you use gcc ver 7.3 with Ubuntu, the dynamic link of EISL does not work.
I am planning to make an OpenGL library.
I got basic IPv6 to work with library/tcpip.lsp, but it's not ready to submit a pull request yet. My change switches to IPv6-only mode which isn't what is required.
The OpenLisp interpreter has two ways to select IPv6 operation:
*default-ip-version*
&rest
arguments to various functions like socket
& connect
For now it looks easier to just do the dynamic variable. What do you think?
using CUDA
(defun fib* (n)
(cond ((= n 1.0) 1.0)
((= n 2.0) 1.0)
(t (+ (fib* (- n 1.0)) (fib* (- n 2.0))))))
compile of + need to be considerd GC
Incorrect array reference.
I had to look at the source code to find out what the supported switches are (-r
and -c
apparently).
From the docs I'm aware of limitations with nested functions, but I don't think this is the problem.
Consider the following:
(defun f (str)
(let ((substr (subseq str 0 3)))
(format (standard-output) "~A~%" substr)))
This will load fine into the interpreter, but if you try to compile it you'll get a "type inference//Not a cons at car NIL" error.
Similarly, if you try to compile
(defun f (str)
(let ((substr str))
(format (standard-output) "~A~%" substr)))
you get a "type inference//Not a class at subclassp " error.
What does compile with no errors is
(defun f (str)
(let ((substr str))
(format (standard-output) "~A~%" str)))
Following on from pull request #50, I can't load the benchmarks. To reproduce:
make DEBUG=1
gdb ./eisl
...
(load "bench/runbench.lsp")
crashes with a 110k-deep backtrace. I haven't been able to figure out any more yet.
Warning will be issued when compiling with the latest GCC of Raspai 3.
when name of function include '?', error.
gcc -O3 -Wall -c cell.c -lm -ldl
gcc -O3 -Wall -c syntax.c -lm -ldl
cc: warning: cc-lm: 'linker' input unused [-Wunused-command-line-argument]:
warning: cc-lm: 'linker' input unused [-Wunused-command-line-argument]:
warning: cc-ldl: 'linker' input unused [-Wunused-command-line-argument]:
warning: -ldl: 'linker' input unused [-Wunused-command-line-argument]
When ctrl+D is pressed in the editable REPL, it only deletes the char on the right side. It's common for ctrl+D in a REPL to quit if there's no user input on the line.
If I press ctrl+D in eisl -r
, I get the following:
Easy-ISLisp Ver1.5
> Unbound variable at eval <file-end>
debug mode ?(help)
>>Unbound variable at eval <file-end>
debug mode ?(help)
[...]
>>zsh: segmentation fault (core dumped) eisl -r
Following code is compile error.
(boyer-setup)
(defun foo ()
(bar (format (standard-output) "~A " 1)
(format (standard-output) "~A " 2)
(format (standard-output) "~A " 3)))
(defun bar (x y z) nil)
Easy-ISLisp Ver1.83
(load "tests/order.lsp")
T
(foo)
1 2 3 NIL
(load "tests/order.o")
T
(foo)
3 2 1 NIL
bug.
segmentation fault
(defglobal g 10)
G
(setq g 20)
20
(setq g 30) <= completion
Segmentation fault (core dumped)
In traverse.lsp type inferencer invoke error.
(let ((one 1))
(foo oen))
It is desirable that the compiler can detect
macro wrong argument error.
If you type #x42 at the REPL, it should be read and printed as decimal 66. However, for master/HEAD this fails.
The root cause is commit f66b7be , in particular the insertion of a break
to stop a switch/case fallthrough. I'll create a pull request for the short 2-line "fix". But I'm not certain that I have the correct fix, was there some reason for putting in that break statement?
This probably affects octal and binary literals too.
let syntax that has no body, type inferencer stop.
(c-include "<stdio.h>")
(defun ma (a x b)
(c-lang "res=A*X+B;"))
Easy-ISLisp Ver0.91
(compile-file "test.lsp")
type inference
Illegal input at read NIL
debug mode ?(help)
main.c:88:18: warning: implicit conversion from enumeration type 'toktype' to different enumeration type 'backtrack' [-Wenum-conversion]
token stok = {GO,OTHER};
~ ^~~~~
function.c:295:13: error: expected parameter declarator
init_f0(0,(tfunc)checkgbc);
^
function.c:295:13: error: expected ')'
function.c:295:12: note: to match this '('
init_f0(0,(tfunc)checkgbc);
^
function.c:295:5: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
init_f0(0,(tfunc)checkgbc);
^
function.c:296:13: error: expected parameter declarator
init_f0(1,(tfunc)gbc);
^
function.c:296:13: error: expected ')'
function.c:296:12: note: to match this '('
init_f0(1,(tfunc)gbc);
^
function.c:296:5: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
init_f0(1,(tfunc)gbc);
^
function.c:297:13: error: expected parameter declarator
init_f0(2,(tfunc)freshcell);
^
function.c:297:13: error: expected ')'
function.c:297:12: note: to match this '('
init_f0(2,(tfunc)freshcell);
^
function.c:297:5: warning: bignum.c:977:13: warning: absolute value function 'abs' given an argument of type 'long long' but has parameter of type 'int' which may cause truncation of value
[-Wabsolute-value]
j = abs(j);
^
bignum.c:977:13: note: use function 'llabs' instead
j = abs(j);
^~~
llabs
type specifier missing, defaults to 'int' [-Wimplicit-int]
init_f0(2,(tfunc)freshcell);
bignum.c:1010:13: warning: absolute value function 'abs' given an argument of type 'long long' but has parameter of type 'int' which may cause truncation of value
[-Wabsolute-value]
j = abs(j);
^
^bignum.c:1010:13: note: use function 'llabs' instead
j = abs(j);
^~~
llabs
function.c:298:13: error: expected parameter declaratorbignum.c:1051:13: warning: absolute value function 'abs' given an argument of type 'long long' but has parameter of type 'int' which may cause truncation of value
[-Wabsolute-value]
j = abs(j);
^
bignum.c:1051:13: note: use function 'llabs' instead
j = abs(j);
^~~
llabs
init_f0(3,(tfunc)freecell);
^
function.c:298:13: error: expected ')'
function.c:298:12: note: to match this '('
init_f0(3,(tfunc)freecell);
^
function.c:298:5: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
init_f0(3,(tfunc)freecell);
^
function.c:299:13: error: expected parameter declarator
init_f0(10,(tfunc)shelterpop);
^
function.c:299:13: error: expected ')'
function.c:299:12: note: to match this '('
init_f0(10,(tfunc)shelterpop);
^
function.c:299:5: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
init_f0(10,(tfunc)shelterpop);
^
function.c:300:13: error: expected parameter declarator
init_f0(11,(tfunc)pop);
gcc -O3 -Wall -c error.c -lm -ldl
^
function.c:300:13: error: expected ')'
function.c:300:12: note: to match this '('
init_f0(11,(tfunc)pop);
^
function.c:300:5: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
cc: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
cc: warning: -ldl: 'linker' input unused [-Wunused-command-line-argument]
init_f0(11,(tfunc)pop);
^
function.c:301:13: error: expected parameter declarator
init_f0(12,(tfunc)get_dynpt);
^
function.c:301:13: error: expected ')'
function.c:301:12: note: to match this '('
init_f0(12,(tfunc)get_dynpt);
^
function.c:301:5: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
init_f0(12,(tfunc)get_dynpt);
^
function.c:304:13: error: expected parameter declarator
init_f1(0,(tfunc)car);
^
function.c:304:13: error: expected ')'
function.c:304:12: note: to match this '('
init_f1(0,(tfunc)car);
^
function.c:304:5: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
init_f1(0,(tfunc)car);
^
function.c:305:13: error: expected parameter declarator
init_f1(1,(tfunc)cdr);
^
function.c:305:13: error: expected ')'
function.c:305:12: note: to match this '('
init_f1(1,(tfunc)cdr);
^
function.c:305:5: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
init_f1(1,(tfunc)cdr);
^
function.c:306:13: error: expected parameter declarator
init_f1(2,(tfunc)cadr);
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
I tested with $error verification code. There are many bad cases.
need to shelterpop for copy.
I wrote this code for Openlisp originally, it only works on Unix platforms:
Contents of run.lsp
:
(defun gets (prompt)
(format (standard-output) prompt)
(with-open-input-file (in "/dev/stdin")
(read-line in nil)))
(format (standard-output) "Word: ~A~%" (gets "> "))
(format (standard-output) "Word: ~A~%" (gets "> "))
(format (standard-output) "Word: ~A~%" (gets "> "))
Output:
echo -ne "foo\nbar\nbaz" | eisl -s run.lsp
> Word: foo
> Word: NIL
> Word: NIL
If I adjust gets
to this:
(defun gets (prompt)
(format (standard-output) prompt)
(read-line (standard-input) nil))
The output looks a bit better, but fails reading the last line (as it's not terminated with newline):
; ; echo -ne "foo\nbar\nbaz" | eisl -s run.lsp
> Word: foo
> Word: bar
> Easy-ISLisp Ver1.6
For some reason it also prints out the version. What's with that?
(array-dimensions #2f((((1.0 2.0 3.0) (4.0 5.0 6.0) (7.0 8.0 9.0)))))
(1 1)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.