It has been a long time since I've organized parking for a complex airport, but this is what I remember, in order of approximate priority:
1. The radius of the parking spot MUST be equal or larger than the radius of the aircraft, or it will not park there, no matter what.
2. If the parking code of the plane matches one of the parking codes of a parking spot, it will be preferred. If there are multiple spots with the same parking code:
2a. The spot with the parking code in the leftmost position is preferred. I.e. if the plane's code is ABC, then a spot with ABC XYZ is preferred over XYZ ABC.
2b. The spot with the same parking type (Gate, etc.) is preferred.
2c. Gate spots are preferred over Gate A, etc.
2d. The spot with the parking radius closest to the radius of the plane is preferred.
3. If there is no matching parking code for the plane, it will prefer spots with no parking codes. The priorities in 2b, 2c, and 2d apply here too.
4. Other than #1, if there is a spot available a plane will park there if it has to, no matter the priority. It is first come, first served. If a plane loading early happens to park at a spot that has parking code that was intended for a plane that loads later, too bad. You need to provide sufficient overflow parking so each plane gets its desired spot. This usually requires lots of testing at different days and times.
Hope this helps,