Constructing finite-dimensional codes with optical continuous variables