git @ Cat's Eye Technologies Fountain / master eg / anbncn-expanded.fountain
master

Tree @master (Download .tar.gz)

anbncn-expanded.fountain @masterraw · history · blame

// This doesn't quite work, and we will need to think about this.
// To be more precise, it works for parsing and generation,
// when `n` is specified.  Generation is not currently expected
// to be possible when `n` is not specified, but parsing is.
// But this cannot parse with unspecified `n`, because when `n`
// is unspecified, `a = n` succeeds (is true), while `~a = n`
// does not succeed, so the "else" branch is taken immediately,
// with a=0.

Goal<n> ::= <. a = 0 .> Loop0<a, n>
            <. b = 0 .> Loop1<b, n>
            <. c = 0 .> Loop2<c, n>
            ;
Loop0<a, n> ::= <. ~a = n .> "a" <. a += 1 .> Loop0<a, n>
              | <. a = n .> ;
Loop1<b, n> ::= <. ~b = n .> "b" <. b += 1 .> Loop1<b, n>
              | <. b = n .>;
Loop2<c, n> ::= <. ~c = n .> "c" <. c += 1 .> Loop2<c, n>
              | <. c = n .>;