source: tests/generator/fibonacci.cfa @ 427854b

arm-ehjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-expr
Last change on this file since 427854b was 427854b, checked in by Thierry Delisle <tdelisle@…>, 20 months ago

First draft implementation of generators, still missing error checking, testing and clean-up

  • Property mode set to 100644
File size: 722 bytes
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// fibonacci.cfa
8//
9// Author           : Thierry Delisle
10// Created On       : Mon Mar  1 16:54:23 2020
11// Last Modified By :
12// Last Modified On :
13// Update Count     :
14//
15
16generator Fib {
17        int fn1, fn;
18};
19
20void main(Fib & b) with (b) {
21        [fn1, fn] = [1, 0];
22        for () {
23                suspend;
24                [fn1, fn] = [fn, fn + fn1];
25        }
26}
27
28int main() {
29        Fib f1, f2;
30        for ( 10 ) {
31                resume( f1 );
32                resume( f2 );
33                printf("%d %d\n", f1.fn, f2.fn);
34        }
35
36}
37
38// Local Variables: //
39// tab-width: 4 //
40// compile-command: "cfa fibonacci.cfa" //
41// End: //
Note: See TracBrowser for help on using the repository browser.