class Pegmatite::Pattern::Label
- Pegmatite::Pattern::Label
- Pegmatite::Pattern
- Reference
- Object
Overview
Pattern::Label is used to provide a symbolic name for a pattern, usually for the purposes of producing a token that marks the range of bytes that was matched by the child pattern, though if @tokenize is set to false, then no token will be produced and the name is used only for description, which is useful for making clearer error messages when the match fails.
If the child pattern also produces tokens, those tokens will appear after the token that was created by this Pattern::Label, and these can be distinguished in the token stream by the fact that all such tokens will have offset ranges that are sub-ranges of the offset range of the prior.
Returns the result of the child pattern's parsing, possibly preceded with a new token whose symbol is the symbolic name assigned to this pattern.