[515989c] | 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 | // waitfor.c -- |
---|
| 8 | // |
---|
| 9 | // Author : Peter A. Buhr |
---|
| 10 | // Created On : Wed Aug 30 17:53:29 2017 |
---|
| 11 | // Last Modified By : Peter A. Buhr |
---|
[f8cd310] | 12 | // Last Modified On : Fri Mar 22 13:42:11 2019 |
---|
| 13 | // Update Count : 3 |
---|
[515989c] | 14 | // |
---|
| 15 | |
---|
| 16 | #include <stdbool.h> |
---|
| 17 | |
---|
| 18 | int fred() { |
---|
| 19 | int x, z; |
---|
| 20 | |
---|
| 21 | // test waitfor and when |
---|
| 22 | |
---|
| 23 | waitfor( x ); |
---|
| 24 | |
---|
| 25 | waitfor( x ) { |
---|
| 26 | } |
---|
| 27 | |
---|
| 28 | waitfor( x, z ) { |
---|
| 29 | } |
---|
| 30 | |
---|
| 31 | when( true ) waitfor( x ); |
---|
| 32 | |
---|
| 33 | when( true ) waitfor( x ) { |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | waitfor( x ); |
---|
| 37 | or waitfor( y ); |
---|
| 38 | |
---|
| 39 | waitfor( x, z ); |
---|
| 40 | or waitfor( y ); |
---|
| 41 | |
---|
| 42 | when( true ) waitfor( x ); |
---|
| 43 | or when( true ) waitfor( y ); |
---|
| 44 | |
---|
| 45 | when( true ) waitfor( x, z ); |
---|
| 46 | or when( true ) waitfor( y ); |
---|
| 47 | |
---|
| 48 | waitfor( x ) { |
---|
| 49 | } or waitfor( y ) { |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | waitfor( x, z ) { |
---|
| 53 | } or waitfor( y ) { |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | when( true ) waitfor( x ) { |
---|
| 57 | } or when( true ) waitfor( y ) { |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | waitfor( x ); |
---|
| 61 | or waitfor( y ) { |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | when( true ) waitfor( x ); |
---|
| 65 | or when( true ) waitfor( y ) { |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | waitfor( x ) { |
---|
| 69 | } or waitfor( y ); |
---|
| 70 | |
---|
| 71 | when( true ) waitfor( x ) { |
---|
| 72 | } or when( true ) waitfor( y ); |
---|
| 73 | |
---|
| 74 | // test when, waitfor and else |
---|
| 75 | |
---|
| 76 | waitfor( x ); |
---|
| 77 | or else; |
---|
| 78 | |
---|
| 79 | when( true ) waitfor( x ); |
---|
| 80 | or else; |
---|
| 81 | |
---|
| 82 | when( true ) waitfor( x, z ); |
---|
| 83 | or else; |
---|
| 84 | |
---|
| 85 | waitfor( x ) { |
---|
| 86 | } or else { |
---|
| 87 | } |
---|
| 88 | |
---|
| 89 | when( true ) waitfor( x ) { |
---|
| 90 | } or else { |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | waitfor( x ); |
---|
| 94 | or else { |
---|
| 95 | } |
---|
| 96 | |
---|
| 97 | when( true ) waitfor( x ); |
---|
| 98 | or else { |
---|
| 99 | } |
---|
| 100 | |
---|
| 101 | when( true ) waitfor( x, z ); |
---|
| 102 | or else { |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | waitfor( x ) { |
---|
| 106 | } or else; |
---|
| 107 | |
---|
| 108 | when( true ) waitfor( x ) { |
---|
| 109 | } or else; |
---|
| 110 | |
---|
| 111 | waitfor( x ); |
---|
| 112 | or when( true ) else; |
---|
| 113 | |
---|
| 114 | when( true ) waitfor( x ); |
---|
| 115 | or when( true ) else; |
---|
| 116 | |
---|
| 117 | when( true ) waitfor( x, z ); |
---|
| 118 | or when( true ) else; |
---|
| 119 | |
---|
| 120 | waitfor( x ) { |
---|
| 121 | } or when( true ) else { |
---|
| 122 | } |
---|
| 123 | |
---|
| 124 | when( true ) waitfor( x ) { |
---|
| 125 | } or when( true ) else { |
---|
| 126 | } |
---|
| 127 | |
---|
| 128 | waitfor( x ); |
---|
| 129 | or when( true ) else { |
---|
| 130 | } |
---|
| 131 | |
---|
| 132 | when( true ) waitfor( x ); |
---|
| 133 | or when( true ) else { |
---|
| 134 | } |
---|
| 135 | |
---|
| 136 | when( true ) waitfor( x, z ); |
---|
| 137 | or when( true ) else { |
---|
| 138 | } |
---|
| 139 | |
---|
| 140 | waitfor( x ) { |
---|
| 141 | } or when( true ) else; |
---|
| 142 | |
---|
| 143 | when( true ) waitfor( x ) { |
---|
| 144 | } or when( true ) else; |
---|
| 145 | |
---|
| 146 | // test when, waitfor and timeout |
---|
| 147 | |
---|
| 148 | waitfor( x ); |
---|
| 149 | or timeout( 3 ); |
---|
| 150 | |
---|
| 151 | waitfor( x, z ); |
---|
| 152 | or timeout( 3 ); |
---|
| 153 | |
---|
| 154 | when( true ) waitfor( x ); |
---|
| 155 | or timeout( 3 ); |
---|
| 156 | |
---|
| 157 | waitfor( x ) { |
---|
| 158 | } or timeout( 3 ) { |
---|
| 159 | } |
---|
| 160 | |
---|
| 161 | when( true ) waitfor( x ) { |
---|
| 162 | } or timeout( 3 ) { |
---|
| 163 | } |
---|
| 164 | |
---|
| 165 | when( true ) waitfor( x, z ) { |
---|
| 166 | } or timeout( 3 ) { |
---|
| 167 | } |
---|
| 168 | |
---|
| 169 | when( true ) waitfor( x ) { |
---|
| 170 | } or when ( true ) timeout( 3 ) { |
---|
| 171 | } |
---|
| 172 | |
---|
| 173 | when( true ) waitfor( x, z ) { |
---|
| 174 | } or when ( true ) timeout( 3 ) { |
---|
| 175 | } |
---|
| 176 | |
---|
| 177 | waitfor( x ); |
---|
| 178 | or timeout( 3 ) { |
---|
| 179 | } |
---|
| 180 | |
---|
| 181 | when( true ) waitfor( x ); |
---|
| 182 | or timeout( 3 ) { |
---|
| 183 | } |
---|
| 184 | |
---|
| 185 | when( true ) waitfor( x ); |
---|
| 186 | or when( true ) timeout( 3 ) { |
---|
| 187 | } |
---|
| 188 | |
---|
| 189 | waitfor( x ) { |
---|
| 190 | } or timeout( 3 ); |
---|
| 191 | |
---|
| 192 | when( true ) waitfor( x ) { |
---|
| 193 | } or timeout( 3 ); |
---|
| 194 | |
---|
| 195 | when( true ) waitfor( x ) { |
---|
| 196 | } or when( true ) timeout( 3 ); |
---|
| 197 | |
---|
| 198 | // test when, waitfor, timeout and else |
---|
| 199 | |
---|
| 200 | waitfor( x ) { |
---|
| 201 | } or timeout( 3 ) { |
---|
| 202 | } or when( true ) else {} |
---|
| 203 | |
---|
| 204 | when( true ) waitfor( x ) { |
---|
| 205 | } or timeout( 3 ) { |
---|
| 206 | } or when( true ) else {} |
---|
| 207 | |
---|
| 208 | waitfor( x ) { |
---|
| 209 | } or timeout( 3 ) { |
---|
| 210 | } or when( true ) else {} |
---|
| 211 | |
---|
| 212 | waitfor( x ) { |
---|
| 213 | } or when( true ) timeout( 3 ) { |
---|
| 214 | } or when( true ) else {} |
---|
| 215 | |
---|
| 216 | when( true ) waitfor( x ) { |
---|
| 217 | } or timeout( 3 ) { |
---|
| 218 | } or when( true ) else {} |
---|
| 219 | |
---|
| 220 | waitfor( x ) { |
---|
| 221 | } or when( true ) timeout( 3 ) { |
---|
| 222 | } or when( true ) else {} |
---|
| 223 | |
---|
| 224 | when( true ) waitfor( x ) { |
---|
| 225 | } or when( true ) timeout( 3 ) { |
---|
| 226 | } or when( true ) else {} |
---|
| 227 | |
---|
| 228 | // test quasi-keywords "or" and "timeout" |
---|
| 229 | |
---|
| 230 | int or, timeout; |
---|
| 231 | waitfor( timeout, 7 ) 3; |
---|
| 232 | waitfor( timeout, 7 ) 3; or waitfor( timeout, 7 ) 3; |
---|
| 233 | when( or ) waitfor( or, ) { 4; } or timeout( 1 ) 3; |
---|
| 234 | when( 3 ) waitfor( or, 2 ) 4; or else 4; |
---|
| 235 | when( 3 ) waitfor( or, 3 ) 4; or when( or ) timeout( or ) 4; or when( or ) else timeout; |
---|
| 236 | when( 3 ) waitfor( or, or ) 3; or when( or ) waitfor( or, timeout ) 4; or else 4; |
---|
| 237 | when( 3 ) waitfor( or, or ) 3; or waitfor( or, 9 ) 4; or when( or ) timeout( timeout ) 4; |
---|
| 238 | when( 3 ) waitfor( or, 3 ) 3; or waitfor( or, 7 ) or; or timeout( 1 ) or; or when( 3 ) else or; |
---|
| 239 | |
---|
| 240 | // test else selection |
---|
| 241 | |
---|
| 242 | if ( or > timeout ) waitfor( or ) 3; |
---|
| 243 | else waitfor( timeout ) 4; |
---|
| 244 | } |
---|
| 245 | |
---|
| 246 | // Local Variables: // |
---|
| 247 | // tab-width: 4 // |
---|
[f8cd310] | 248 | // compile-command: "cfa waitfor.cfa" // |
---|
[515989c] | 249 | // End: // |
---|