kevinlawler / kona

Open-source implementation of the K programming language
ISC License
1.36k stars 138 forks source link

;\\3 #501

Closed tavmem closed 6 years ago

tavmem commented 6 years ago

In k2.8

$ rlwrap -n ~/k2.8/k
K 2.8 2000-10-10 Copyright (C) 1993-2000 Kx Systems
Evaluation. Not for commercial use. 
\ for help. \\ to exit.
  ;\\3
3
,3
  \\3
sh: 3: command not found
domain error
  \\ls
bench  k  Kona.png  k_test  LICENSE  Makefile  misc  README.md  src  verb
  \ls
bench  k  Kona.png  k_test  LICENSE  Makefile  misc  README.md  src  verb

in Kona (the primary problem is the SEG fault):

$ rlwrap -n ~/kona/k
K Console - Enter \ for help
  ;\\3
Segmentation fault (core dumped)
$ rlwrap -n ~/kona/k
K Console - Enter \ for help
  \\3
sh: \3: command not found
domain error
>  \
  \\ls
sh: \ls: command not found
domain error
>  \
  \ls
bench  k  Kona.png  k_test  LICENSE  Makefile  misc  README.md  src  verb

But, as you can see, there are some other inconsistencies

tavmem commented 6 years ago

However, in both k2.8 and kona:

  ;\\ls
value error
ls
^
tavmem commented 6 years ago

Also, in k2.8

K 2.8 2000-10-10 Copyright (C) 1993-2000 Kx Systems
Evaluation. Not for commercial use. 
\ for help. \\ to exit.
  \3
domain error

but, kona seems to yield a null response:

$ rlwrap -n ~/kona/k
K Console - Enter \ for help
  \3

however,

$ rlwrap -n ~/kona/k
K Console - Enter \ for help
  _n ~ \3
3
0
  3 ~ \3
3
1
  a:\3
syntax error
>  \
  a
value error
a
^
  a: \3
3
  a
3
tavmem commented 6 years ago

And in k2.8, there similar inconsistent results:

$ rlwrap -n ~/k2.8/k
K 2.8 2000-10-10 Copyright (C) 1993-2000 Kx Systems
Evaluation. Not for commercial use. 
\ for help. \\ to exit.
  a: \3
3
  a
3
  b:\3
syntax error
b:\3
 ^
parse error
tavmem commented 6 years ago

After commit c047ce9b636473b9ceca6fcadeed50274d335f6f

$ rlwrap -n ~/kona/k
K Console - Enter \ for help
  \3
domain error
>  
tavmem commented 6 years ago

Note that in k2.8

$ rlwrap -n ~/k2.8/k
K 2.8 2000-10-10 Copyright (C) 1993-2000 Kx Systems
Evaluation. Not for commercial use. 
\ for help. \\ to exit.
  \\3
sh: 3: command not found
domain error

but in kona:

$ rlwrap -n ~/kona/k
K Console - Enter \ for help
  \\3
sh: \3: command not found
domain error
> 

Looks like another instance of the problem described in #481 Parsing (and token capture) in k2.8 is from right to left. Parsing (and token capture) n kona is from left to right.

tavmem commented 6 years ago

Interesting:

$ rlwrap -n ~/kona/k
K Console - Enter \ for help
  ;\\3
Segmentation fault (core dumped)
$ rlwrap -n ~/konak/k
K Console - Enter \ for help
  ; \\3
3
,3

The second result is what we want in both cases.

tavmem commented 6 years ago

The first instance is being parsed as (end)(scan)(scan)(3)

$ rlwrap -n ~/kona/k
K Console - Enter \ for help
  ;\\3
Segmentation fault (core dumped)

The second instance is being parsed as (end)(trace)(scan)(3)

$ rlwrap -n ~/konak/k
K Console - Enter \ for help
  ; \\3
3
,3
bakul commented 6 years ago

On Mon, 19 Mar 2018 21:15:18 -0000 Tom Szczesny notifications@github.com wrote:

Closed #501 via f1a1b95d7cafdaf8b151f87482db84c8f7997cda.

With the latest changes:

$ ./k
...
  ;\\3
3
,3
  (\\3)
[2]    21360 segmentation fault  ./k

Compare with

$ k
...
  (\\3)
3
,3