mattunlv / ProcessJ-main-branch-old

ProcessJ Compiler Project
2 stars 4 forks source link

Replicated ALTs in ProcessJ #8

Open cabelshrestha opened 7 years ago

cabelshrestha commented 7 years ago

What is a replicated ALT?

So, in occam:

ALT i=0 FOR n
  c[i] ? any 
    some process

is the same as:

ALT
  c[0] ? any
    some process
  c[1] ? any
    some process
 …
 c[n] ? any
    some process

there are two problems:

  1. the grammar doesn’t allow it yet (we never talked about the proper syntax)
  2. how does this work at runtime? can it work like we do with the replicate par: at runtime we just build the alt object by running the loop (what happened if it never terminates?)

    so something like:

    alt (i=0; i<=n; i++)
      …

problem, as usual is that what can appear between ( and ) is VERY general.

here is version of dining philosophers code that should not deadlock after replicated ALT is added: phil2.pj.txt

matt

cabelshrestha commented 7 years ago

I guess the ball's in your court on this one too?

mattunlv commented 7 years ago

have added and pushed code that syntactically accepts it - but there is no checking and it is not yet added to the parse tree.

mattunlv commented 7 years ago

This is now in the AST - the AltStat has init(), expr(), and incr() just like the for statement as well as a predicate isReplicated() that returns true if it is a replicated alt. The syntax is:

[pri] alt [(init ; expr; incr)] {

}