forked from glen/fostr
Glen Whitney
b9c8532899
Note that ultimately a terminated sequence may have a slightly different semantics (applying streams to `_|_`, most likely) but for now they don't.
22 lines
760 B
Plaintext
22 lines
760 B
Plaintext
module desugar
|
|
imports libstrategolib signatures/-
|
|
|
|
rules
|
|
/* ISequence() and Prior() are just noise for more expressions in sequence,
|
|
put in to get the layout rules right. So we remove them and collapse
|
|
all occurrence of them into one big Sequence() call on a list.
|
|
|
|
This is slightly tricky because there might not be any Sequence() call
|
|
at the top level, but yet an ISequence(). So we do it in two passes,
|
|
first converting ISequence()s to Sequence()s, and then collapsing
|
|
Sequence()s.
|
|
*/
|
|
deISe: ISequence(Prior(l),x) -> Sequence(<conc>(l, [x]))
|
|
|
|
enList: x -> [x]
|
|
seqFlatten: Sequence(l) -> Sequence(<mapconcat(?Sequence(<id>) <+ enList)>l)
|
|
|
|
strategies
|
|
|
|
desugar-fostr = bottomup(try(deISe <+ seqFlatten))
|
|
|