kaluma-project / kaluma

A tiny JavaScript runtime for RP2040 (Raspberry Pi Pico)
https://kalumajs.org
Apache License 2.0
648 stars 37 forks source link

REPL improvements #496

Open davidmoshal opened 2 years ago

davidmoshal commented 2 years ago

1) ability to enter multi-line statements.

kaluma-repl-1

2) tab completing (like EspruinoJS).

niklauslee commented 2 years ago

About 2, is that works only for predefined funs and vars? Or, works exactly like typical code completion in VSCode, etc.?

davidmoshal commented 2 years ago

Works exactly like VSCode. Any new var / const can be tab-completed. You should try it out. If we had that working, then I'd be willing to work on a user interface for Kaluma similar to Espruino.

niklauslee commented 2 years ago

It doesn't seem easy with JerryScript API. Any ideas are welcome.

davidmoshal commented 2 years ago

I'm no C expert sadly, maybe the answer is in the Espruino codebase.

Looking at the Jerryscript api, there is the ability to look at types and enumerate their properties. https://jerryscript.net/api-reference/#jerry_object_type_t

There is also a context: https://jerryscript.net/api-reference/#jerry_context_t

So. presumably given the context, and the ability to enumerate the properties of an object tab completion should be possible, no?

niklauslee commented 2 years ago

For the feature I think it is required to build partial AST (parsing incomplete JS expression).