Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| language:controlflow [2019/04/18 18:25] – [Selections] rajit | language:controlflow [2022/07/17 12:07] (current) – [Loops] rajit | ||
|---|---|---|---|
| Line 11: | Line 11: | ||
| An example of the loop construct in ACT is shown below: | An example of the loop construct in ACT is shown below: | ||
| - | < | + | < |
| ( i : 10 : bool x[i..i]; ) | ( i : 10 : bool x[i..i]; ) | ||
| </ | </ | ||
| Line 20: | Line 20: | ||
| range '' | range '' | ||
| - | < | + | < |
| bool x[0..0]; | bool x[0..0]; | ||
| bool x[1..1]; | bool x[1..1]; | ||
| Line 31: | Line 31: | ||
| is shown below: | is shown below: | ||
| - | < | + | < |
| register r[1..8]; | register r[1..8]; | ||
| (i : 1..8 : r[i](in[i], | (i : 1..8 : r[i](in[i], | ||
| Line 48: | Line 48: | ||
| command language. | command language. | ||
| - | < | + | < |
| pint i; | pint i; | ||
| i=0; | i=0; | ||
| Line 65: | Line 65: | ||
| In production rule bodies, the loop | In production rule bodies, the loop | ||
| - | < | + | < |
| (&i:3: x[i]) | (&i:3: x[i]) | ||
| </ | </ | ||
| expands to | expands to | ||
| - | < | + | < |
| x[0] & x[1] & x[2] | x[0] & x[1] & x[2] | ||
| </ | </ | ||
| Line 75: | Line 75: | ||
| syntax). The ''&'' | syntax). The ''&'' | ||
| instantiated for different values of '' | instantiated for different values of '' | ||
| + | |||
| + | The syntactic replication construct is written as follows: | ||
| + | <code act> | ||
| + | (sym id : range : body ) | ||
| + | </ | ||
| + | The '' | ||
| + | <code act> | ||
| + | | ||
| + | </ | ||
| + | where '' | ||
| Line 82: | Line 92: | ||
| syntax of a selection statement is: | syntax of a selection statement is: | ||
| - | < | + | < |
| [ boolean_expression -> body | [ boolean_expression -> body | ||
| [] boolean_expression -> body | [] boolean_expression -> body | ||
| Line 95: | Line 105: | ||
| something special for register 0 as follows: | something special for register 0 as follows: | ||
| - | < | + | < |
| (i : 32 : | (i : 32 : | ||
| - | [ i = 0 -> r0(in[i], | + | [ i = 0 -> r0(in[i], |
| - | [] else -> r[i](in[i], | + | [] else -> r[i](in[i], |
| ] | ] | ||
| ) | ) | ||
| Line 116: | Line 126: | ||
| definition can be used to create a tree structure. | definition can be used to create a tree structure. | ||
| - | < | + | < |
| template< | template< | ||
| defproc tree (bool a[N]) | defproc tree (bool a[N]) | ||
| { | { | ||
| - | [ N = 1 -> leaf l(a[0]) | + | [ N = 1 -> leaf l(a[0]); |
| [] N > 1 -> tree< | [] N > 1 -> tree< | ||
| - | | + | |
| ] | ] | ||
| } | } | ||