ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change
on this file since ecd4923 was
2f22cc4,
checked in by Peter A. Buhr <pabuhr@…>, 8 years ago
|
more refactoring of parser code
|
-
Property mode set to
100644
|
File size:
2.7 KB
|
Rev | Line | |
---|
[2f22cc4] | 1 | // |
---|
| 2 | // Cforall Version 1.0.0 Copyright (C) 2016 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 | // labelledExit.c -- |
---|
| 8 | // |
---|
| 9 | // Author : Peter A. Buhr |
---|
| 10 | // Created On : Wed Aug 10 07:29:39 2016 |
---|
| 11 | // Last Modified By : Peter A. Buhr |
---|
| 12 | // Last Modified On : Wed Aug 10 07:30:15 2016 |
---|
| 13 | // Update Count : 1 |
---|
| 14 | // |
---|
| 15 | |
---|
[10dc7491] | 16 | int foo() { |
---|
[62edde5] | 17 | int i; |
---|
| 18 | int x, y; |
---|
| 19 | |
---|
| 20 | x = 0; y = 0; |
---|
| 21 | |
---|
| 22 | // block, labelled exits |
---|
| 23 | |
---|
| 24 | Block: { |
---|
| 25 | if ( x == y ) { |
---|
| 26 | for ( ; i < y; ) { |
---|
| 27 | y += 1; |
---|
| 28 | if ( y < 10 ) break Block; |
---|
| 29 | } |
---|
| 30 | } |
---|
| 31 | } |
---|
| 32 | |
---|
| 33 | // loops, labelled exits |
---|
| 34 | |
---|
| 35 | w1: while ( y == 10 ); |
---|
| 36 | |
---|
| 37 | w2: while ( x < 10 ) { |
---|
| 38 | while (y < 5 ) { |
---|
| 39 | if ( y == 3 ) break w2; |
---|
| 40 | } |
---|
| 41 | x += 1; |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | A: for ( i = 0; i < 10; i += 1 ) { |
---|
| 45 | B: for ( i = 0; i < 10; i += 1 ) { |
---|
| 46 | C: for ( i = 0; i < 10; i += 1 ) { |
---|
| 47 | goto A; |
---|
| 48 | goto B; |
---|
| 49 | goto C; |
---|
| 50 | continue A; |
---|
| 51 | continue B; |
---|
| 52 | continue C; |
---|
| 53 | continue; |
---|
| 54 | break A; |
---|
| 55 | break B; |
---|
| 56 | break C; |
---|
| 57 | break; |
---|
| 58 | } |
---|
| 59 | } |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | D: for ( ;; ) { |
---|
| 63 | break D; |
---|
| 64 | continue D; |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | Z : i += 1; |
---|
| 68 | goto Z; |
---|
| 69 | X: Y: for ( ;; ) { |
---|
| 70 | i += 1; |
---|
| 71 | if ( i > 5 ) continue X; |
---|
| 72 | if ( i < 5 ) break X; |
---|
| 73 | if ( i < 5 ) break Y; |
---|
| 74 | break; |
---|
| 75 | } |
---|
| 76 | XX: for ( ;; ) { |
---|
| 77 | YY: for ( ;; ) { |
---|
| 78 | ZZ: for ( ;; ) { |
---|
| 79 | i += 1; |
---|
| 80 | if ( i > 5 ) continue XX; |
---|
| 81 | if ( i < 5 ) continue YY; |
---|
| 82 | if ( i < 5 ) continue ZZ; |
---|
| 83 | if ( i > 5 ) break XX; |
---|
| 84 | if ( i < 5 ) break YY; |
---|
| 85 | if ( i < 5 ) break ZZ; |
---|
| 86 | break; |
---|
| 87 | } |
---|
| 88 | } |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | for ( ;; ) ; |
---|
| 92 | for ( int i = 0 ;; ) ; |
---|
| 93 | for ( ; i < 0; ) ; |
---|
| 94 | for ( ; ; i += 1 ) ; |
---|
| 95 | L0: L1: L2: L3: L4: L5: L6: L7: L8: L9: |
---|
| 96 | L10: L11: L12: L13: L14: L15: L16: L17: L18: L19: |
---|
| 97 | L20: L21: L22: L23: L24: L25: L26: L27: L28: L29: |
---|
| 98 | L31: L32: L33: L34: |
---|
| 99 | for ( ;; ) { |
---|
| 100 | break L0; |
---|
| 101 | } |
---|
| 102 | |
---|
| 103 | // switch/choose, labelled exits |
---|
| 104 | |
---|
| 105 | Switch: switch ( i ) { |
---|
| 106 | default: |
---|
| 107 | i += 1; |
---|
| 108 | case 0: |
---|
| 109 | i += 1; |
---|
| 110 | break Switch; |
---|
| 111 | case 1: |
---|
| 112 | switch ( i ) { |
---|
| 113 | case 0: |
---|
| 114 | break Switch; |
---|
| 115 | default: |
---|
| 116 | ; break; |
---|
| 117 | } |
---|
| 118 | } |
---|
| 119 | |
---|
| 120 | Choose: choose ( i ) { |
---|
| 121 | default: |
---|
| 122 | i += 1; |
---|
| 123 | case 0: |
---|
| 124 | i += 1; |
---|
| 125 | break Choose; |
---|
| 126 | case 1: |
---|
| 127 | choose ( i ) { |
---|
| 128 | case 0: |
---|
| 129 | break; |
---|
| 130 | default: |
---|
| 131 | break Choose; |
---|
| 132 | } |
---|
| 133 | fallthru; |
---|
| 134 | case 2: |
---|
| 135 | i += 1; |
---|
| 136 | } |
---|
| 137 | |
---|
| 138 | // computed goto |
---|
[c017d5b] | 139 | // { |
---|
| 140 | // void *array[] = { &&foo, &&bar, &&hack }; |
---|
| 141 | // foo: bar: hack: |
---|
| 142 | // &&foo; |
---|
| 143 | // &&bar; |
---|
| 144 | // goto *array[i]; |
---|
| 145 | // } |
---|
[62edde5] | 146 | |
---|
| 147 | Q: if ( i > 5 ) { |
---|
| 148 | i += 1; |
---|
[540b275] | 149 | break Q; |
---|
| 150 | } |
---|
| 151 | else |
---|
[62edde5] | 152 | i += 1; |
---|
| 153 | } |
---|
| 154 | |
---|
[2f22cc4] | 155 | int main( int argc, char const *argv[] ) { |
---|
[aaf1f4d] | 156 | /* code */ |
---|
| 157 | } |
---|
| 158 | |
---|
[62edde5] | 159 | // Local Variables: // |
---|
| 160 | // tab-width: 4 // |
---|
[2f22cc4] | 161 | // compile-command: "cfa labelledExit.c" // |
---|
[62edde5] | 162 | // End: // |
---|
Note: See
TracBrowser
for help on using the repository browser.