IgnoreMatcher
Last updated
Last updated
An ignore matcher tells the lexer to ignore characters. If you have a language that don't rely on whitespaces you can ignore them or you can use an ignore matcher to allow comments in the code.
The parser is glued by all of the above components and it has some helper methods to make it easier to glue them together.
To ignore comments you can use one of the predefined IgnoreMatchers. The MultiLineCommentIgnoreMatcher
can ignore characters in multiple lines and the SingleLineCommentIgnoreMatcher
ignores comments for a single line. The SingleLineCommentIgnoreMatcher is a special configured MultilineCommentIgnoreMatcher that matches until the line end.
Method | Description | Example |
---|---|---|
An IgnoreMatcher is responsible for advancing the cursor in the lexer based on certain conditions. You can build your own by implementing the IIgnoreMatcher
interface.
Ignore
Skips character by specification, predicate or IgnoreMatcher
lexer.Ignore("\t")
IgnoreWhitespace
Ignores all whitespaces
lexer.IgnoreWhitespace()