padsproj / pads-haskell

Haskell binding for PADS
www.padsproj.org
Other
18 stars 7 forks source link

Generators: order of generation for context-sensitivity #16

Open cronburg opened 5 years ago

cronburg commented 5 years ago

Presently generators annotated on a PADS description get executed (in do-notation-style?) in the order in which they are defined in the description, that is in parsing-order. This makes context-sensitive generators (generators that rely on the value of some other field of the data type) cumbersome because fields can only refer to each other when the reference occurs after (in the file) the referent.

What needs to be done: in the initial step of generating the dataType_genM, we need to do a topological sort of the fields of the data type, where fieldA < fieldB iff the generator for fieldA does not refer in any way to the variable name fieldB. Then the do-notation generator which brings names into scope in the order in which they are generated will function properly (as expected).

cronburg commented 5 years ago

See RecursiveDo: