Breast cancer is responsible for approximately 15% of all cancer-related deaths among women worldwide, and early and accurate diagnosis increases the chances of survival. Over the last decades, several machine learning approaches have been used to improve the diagnosis of this disease, but most of them require a large set of samples for training. Syntactic approaches were barely used in this context, although it can present good results even if the training set has few samples. This article presents a syntactic approach to classify masses as benign or malignant. There were used features extracted from a polygonal representation of masses combined with a stochastic grammar approach to discriminate the masses found in mammograms. The results were compared with other machine learning techniques, and the grammar-based classifiers showed superior performance in the classification task. The best accuracies achieved were from 96% to 100%, indicating that grammatical approaches are robust and able to discriminate the masses even when trained with small samples of images. Syntactic approaches could be more frequently employed in the classification of masses, since they can learn the pattern of benign and malignant masses from a small sample of images achieving similar results when compared to the state of art.