tokay-lang / tokay

Tokay is a programming language designed for ad-hoc parsing, inspired by awk.
https://tokay.dev
MIT License
236 stars 7 forks source link

Run program once over all provided files or in parallel #111

Open phorward opened 1 year ago

phorward commented 1 year ago

Tokay's current implementation runs the provided program separately on every input file: tokay program.tok -- file1 file2 file3 runs tokay.tok on file1, file2 and file3 separately and sequentially. This might not always be intended.

This behavior should be customizable and moved into the VM/Parselet-main layer. awks way, for example, is to run the provided PROGRAM on all files. The nextfile instruction forces to continue the program flow on the next file.

Additionally, tokays current way of running a program sequentially and separately on all provided files could be improved to run on all files simultaneously and in parallel.

This should be configured by command-line switches, and needs further investigation.

So these 3 modes could be useful:

  1. Run PROGRAM on files separately and sequentially (current behavior)
  2. Run PROGRAM on files separately and in parallel (improvement of current behavior)
  3. Run PROGRAM once on all files, sequentially, but keeping the runtime context. This might also require for a awk-style nextfile function or similar.
phorward commented 1 year ago

Partly fixed by 172815a