A mode describes lexical elements of a language and determines the way to detect atomic chunks of meaning. It is a formal description of the behavior of the lexical analyzer. In this sense, a mode is a ‘recognition state’. The means to describe its behavior are pattern-action pairs and event handlers. In pattern action pairs customized actions are associated with the event that a pattern matches in the input stream. Event handlers associate customized actions with events of lexical analysis, such as ‘match failure’ or ‘end of stream’. The inherent pitfalls, to avoid, have been discussed which may lead to surprising behavior or which actually even stall the lexical analyzer.
Mode tags provide convenient features such as line and column number counting, indentation-based scope handling, and skipping irrelevant regions in the input stream. Entry and exit restrictions make it more explicit what mode transitions are actually possible. Modes can be related by inheritance. A particular section discussed how attributes of modes are subject to inheritances.
One section discussed match precedence rules in case of ambiguities.
It has been explained how the commands DEMOTION
and DELETION
can
be used to adapt positional precedence of patterns. A final section elaborated
on pitfalls of potentially surprising behavior and stall conditions.