Ignore:
Timestamp:
Oct 29, 2019, 4:01:24 PM (6 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
773db65, 9421f3d8
Parents:
7951100 (diff), 8364209 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 moved

Legend:

Unmodified
Added
Removed
  • tests/coroutine/fibonacci.cfa

    r7951100 rb067d9b  
    66//
    77// fibonacci.c -- 3-state finite-state machine
    8 
    98//
    109// Author           : Thierry Delisle
    1110// Created On       : Thu Jun  8 07:29:37 2017
    1211// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Fri Apr 27 08:55:31 2018
    14 // Update Count     : 19
     12// Last Modified On : Fri Mar 22 13:40:35 2019
     13// Update Count     : 26
    1514//
    1615
    17 #include <fstream>
    18 #include <coroutine>
     16#include <fstream.hfa>
     17#include <coroutine.hfa>
    1918
    2019coroutine Fibonacci { int fn; };                                                // used for communication
     
    2625        fn = 1;  fn2 = fn1;  fn1 = fn;                                          // 2nd case
    2726        suspend();                                                                                      // restart last resume
    28         for ( ;; ) {
     27        for () {
    2928                fn = fn1 + fn2;  fn2 = fn1;  fn1 = fn;                  // general case
    3029                suspend();                                                                              // restart last resume
     
    3938int main() {
    4039        Fibonacci f1, f2;
    41         for ( int i = 1; i <= 10; i += 1 ) {
    42                 sout | next( f1 ) | next( f2 ) | endl;
     40        for ( 10 ) {                                                                            // print N Fibonacci values
     41                sout | next( f1 ) | next( f2 );
    4342        } // for
    4443}
     
    4645// Local Variables: //
    4746// tab-width: 4 //
    48 // compile-command: "cfa fibonacci.c" //
     47// compile-command: "cfa fibonacci.cfa" //
    4948// End: //
Note: See TracChangeset for help on using the changeset viewer.