Place the basil and pine nuts in a food processor; cover with lid and pulse a few times. (If you are using walnuts instead of pine nuts and they are not already chopped, pulse them a few times first, before adding the basil.) Add the garlic, pulse a few times more.
Slowly add the olive oil in a constant stream while the food processor is on. Stop to scrape down the sides of the food processor with a rubber spatula. Add the grated cheese and pulse again until blended. Add a pinch of salt and freshly ground black pepper to taste.