Parser being too smart with fold expressions
/tmp|=> cat test-fold.sac
int main () {
a = [1,2,3];
return with {
([0] <= iv <= _shape_A_ (a)): _sel_VxA_ (iv, a);
}: fold (_add_SxS_, 0);
}
/tmp|=> ./sac2c/build_d/sac2c_d test-fold.sac
** 1: Loading SAC program ...
**** Locating source code ...
Reading from file "./test-fold.sac" ...
**** Running C preprocessor ...
**** Parsing input file ...
./test-fold.sac:5:12: error:
=> invalid function name `_add_SxS_' found
./test-fold.sac:7:1: error:
=> token `}' expected, `EOF' token found
abort: Failed to construct a syntax tree for `test-fold.sac'
compilation failed while Loading SAC program, 2 error(s).
The problem is that parser expects an identifier, but _add_SxS_
is a keyword, hence the error.
This can be trivially fixed, given that the backend is happy to accept primitive function as a valid object. The question is: what should SPFOLD_FN
be in this case? SPID
or PRF
?