SyntaxTokenParser Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
A token parser that can be used to parse tokens continuously from a source. This parser parses continuously; every call to ParseNextToken() will return the next token in the source text, starting from position 0. SkipForwardTo(Int32) can be used to skip forward in the file to a specific position, and ResetTo(SyntaxTokenParser+Result) can be used to reset the parser to a previously-lexed position.
public sealed class SyntaxTokenParser : IDisposable
type SyntaxTokenParser = class
interface IDisposable
Public NotInheritable Class SyntaxTokenParser
Implements IDisposable
- Inheritance
-
SyntaxTokenParser
- Implements
Remarks
This type is safe to double dispose, but it is not safe to use after it has been disposed. Behavior in such scenarios is undefined.
This type is not thread safe.
Methods
Dispose() | |
ParseLeadingTrivia() |
Parse the leading trivia of the next token from the input at the current position. This will advance the internal position of the
token parser to the end of the leading trivia of the next token. The returned result will have a token with Kind(SyntaxToken)
of None, IsMissing set to |
ParseNextToken() |
Parse the next token from the input at the current position. This will advance the internal position of the token parser to the end of the returned token, including any trailing trivia. |
ParseTrailingTrivia() |
Parse syntax trivia from the current position, according to the rules of trailing syntax trivia. This will advance the internal position of the
token parser to the end of the trailing trivia from the current location. The returned result will have a token with Kind(SyntaxToken)
of None, IsMissing set to |
ResetTo(SyntaxTokenParser+Result) |
Resets the token parser to an earlier position in the input. The parser is reset to the start of the token that was previously parsed, before any leading trivia, with the directive state that existed at the start of the token. |
SkipForwardTo(Int32) |
Skip forward in the input to the specified position. Current directive state is preserved during the skip. |