By default lexer reports rule giving longest possible match. When multiple rules give matches of equal lengths rule defined earlier is chosen. It is possible to reject current match and try next matching rule (defined further in file or giving a shorter match). Rejecting can be done from code defined for currently matched rule.
To enable rejecting Lexer.RejectEnabled option must be set.
Rejecting does not cause lexer to rescan input. Start of currently matched text remains in its position. End of matched text is adjusted in accordance with next rule that fits current input. Effectively length of matched text may decrease.
Two behaviors are possible when using reject functionality. User can:
Macros listed below jump to rule for next match:
Both macros have the same functionality. Reject current match and jump to code for next matched rule. If there is no next match these macros do nothing
Jumps back to first matched rule (one giving longest match). Does nothing when invoked from within code for this rule.
Jumps to code for rule associated with currently active 'match'. This jump is performed unconditionally. When invoked from within code of currently matched rule will jump back to start of it.
Methods listed below do not jump to any location after changing modes:
Switches active match to next alternative. If there is no next alternative does nothing and returns false. Does not jump anywhere.
Switches current match back to first rule giving longest match. Returns false when invoked from within this rule. Does not jump anywhere.
Returns true if current match is the first, longest match