DvvCz / cpkg

A dead simple package manager for C.
MIT License
1 stars 0 forks source link

Subcommand: `repl` #2

Closed DvvCz closed 5 months ago

DvvCz commented 5 months ago

I already added some preparation code for this, it would essentially just detect igcc or bic and run them when the command is invoked.

It's possible that I create my own implementation but it doesn't seem necessary at the moment and may just complicate things.

DvvCz commented 5 months ago

Both projects seem unfortunately stalled / abandoned. Maybe my own implementation is the best route, although I wouldn't promise anything of much quality.

So far all I can think of is:

  1. Parse function declarations, preprocessor macro declarations separately, store them in an array of strings.
  2. Whenever a function statement is parsed, assume it is not a pure function, compile the call alongside previously stored declarations and run the code.

Storing local variables doesn't really seem like it has a good solution. Parsing the C code might be tricky as well, I know that clang outputs a JSON ast, not sure if gcc does as well.