The autocompleter works by traversing the ATN, which is ANTLR4's state machine. To do so, we begin by focusing on the three most common types of transitions: Epsilon, Atomic and Set.
ANTLR4 grammars are commonly used to build parsers and syntax analyzers. However, if you dive deeper you'll find out they also be used to predict what the user is going to type next.