GassaFM / interpr

Toy language to learn parallel computing
MIT License
5 stars 4 forks source link

`-c` enterpreter argument. Idling in syntax check #33

Closed lounres closed 3 years ago

lounres commented 3 years ago

Such code example as

function sum (id, pr, n, a):
    if id != 0:
        send(0, 1)
    else:
        print(receive(0))

is approved by the interpreter called with -c argument. But the interpreter called without the argument states an error:

step 7, id 0, line 5: can only assign with receive

that is correct depending on documentation.

P.S. Used the latest at the moment version of the enterpreter: 0.4

lounres commented 3 years ago

Also

function sum (id, pr, n, a):
    p := 2 * m

is approved but not enterpreted. Is it bug or feature?

GassaFM commented 3 years ago

Compilation (and interpretation) of programs consist of multiple passes. It is convenient to do specific checks in specific passes.

The checks for usage of special functions are done at runtime. Could have been done at compile time too, but a similar amount of effort might have made the functions less special.

Some checks are hard. For example, in a more complex program, it would be hard to check whether m exists in every possible scenario leading to a p := 2 * m line. Akin to the halting problem. Naturally, such checks don't occur.

lounres commented 3 years ago

OK. The second comment is only a clarification question. But the first one is trivial syntax problem.

I mean, "Syntax" paragraph of documentation precisely describes syntax of the language (almost as regular expressions). And there are only one expression where receive can be used: in assignation <var> <assignOp> receive (<from>). So, as I understand, it should be easy to detect the issue. Or am I wrong?