Real to Int

You have to stick to Stan syntax. The while loop would look like this:

real a;
...
{
  int i = 1;
  while (i < a) {
    ... go to town ...
    i = i + 1;
  }
}

The extra layer of brackes is to let you define the variable i as a local variable for the loop.