When do I use labels versus return values?

Monty Zukowski

Return values are provided because every rule is really a method, and people are used to being able to pass parameters into methods and have a return value. You declare this yourself and can do anything you want with it.

Labels are provided to give you access to the predefined attributes of grammar elements like tokens and ASTs. In other words, what token did I just match? What AST did that rule just build? What tree did I just match? ANTLR considers labeled elements to be subclasses of Token or, for trees, objects implementing AST. They are for your convenience.