Changes between Version 44 and Version 45 of IR2


Ignore:
Timestamp:
04/28/21 18:26:34 (5 years ago)
Author:
siegel
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • IR2

    v44 v45  
    133133
    134134=== Notes ===
     135
    135136* Sequences, sets, maps, and relations are immutable.   An assignment using objects of this type creates a new copy of the object, just as with primitive types like `int`.
    136137* The main difference between the array type and the sequence type is that elements of an array are addressable, i.e., one can form a pointer such as `&a[i]`.  This is not possible with sequences, sets, maps, or relations---there is no way to have a pointer to any component of such a type.
    137138* The difference between the function type and map type: a function is really a procedure in the language, so it can modify the state as well as return a value.    This is like the C notion of "function".   A map is a logical partial function: it is defined on some subset of the domain type, it will always "return" the same value on a given input, and reading it cannot modify the state.
    138 
    139139
    140140
     
    161161
    162162{{{
     163lvalue:
     164  | ID
     165  | lvalue '[' expr ']'
     166  | lvalue '.' ID
     167  | '*' expr
     168  ;
    163169expr:
    164     $new(type-name)  /* returns a new arbitrary value of the given type */
    165   |
     170  | lvalue
     171  | STRING
     172  | INT
     173  | REAL
     174  | FLOAT
     175  | expr '+' expr  /* numeric or pointer addition */
     176  | expr '-' expr  /* numeric or pointer subtraction */
     177  | expr '/' expr  /* division */
     178  | expr '%' expr  /* modulo */
     179  | expr '&&' expr  /* logical and */
     180  | expr '||' expr  /* logical or */
     181  | expr '==' expr  /* equality */
     182  | expr '!=' expr  /* inequality */
     183  | expr '[' expr ']'  /* array or map read */
     184  | '!' expr  /* logical not */
     185  | '(' expr ')'
     186  | '*' expr  /* pointer dereference */
     187  | '&' lvalue  /* address-of */
     188  | $new(type-name)  /* returns a new arbitrary value of the given type */
    166189
    167190}}}