kevinlawler / kona

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

Separate parsing step #550

Open tavmem opened 4 years ago

tavmem commented 4 years ago

@Bakul suggested this in a comment on issue #521

My gut feeling is that a separate parsing step would simplify things. 
Such a parsing step would not require a dictionary. For example:

// input expression
// => parsed representation
a+2
=>      (+;`a;2)
+[a;2]
=>      (+;`a;2)
a:b+c
=>      (:;`a;(+;`b;`c))
a:x; if[x>0; f(a-1)]; a
=>      (";";  (:;`a;`x);  (`if; (>;`x;0); (`f;(-;`a;1)));  `a)

The parsed rep. can be directly interpreted and that is where you need 
a global and local dict. No idea how much work this change would be.

Setting it up as a separate issue so it doesn't get lost.