Click or drag to resize

Parser Class

Supports the parsing of text into code objects.
Inheritance Hierarchy
SystemObject
  Nova.ParsingParser

Namespace:  Nova.Parsing
Assembly:  Nova.CodeDOM (in Nova.CodeDOM.dll) Version: 7.44.8391.13415
Syntax
C#
public class Parser : IDisposable

The Parser type exposes the following members.

Constructors
  NameDescription
Public methodParser
Parse source code from the specified CodeUnit.
Top
Properties
  NameDescription
Public propertyChar
The next character to be processed.
Public propertyCurrentConditionalDirectiveState
Get the current conditional directive state.
Public propertyHasNestedPeekedTypeArguments
Return true if the parser has multiple nested peek-ahead type argument lists in progress.
Public propertyHasUnused
Returns true if there are any Unused items.
Public propertyHasUnusedExpression
Returns true if the last Unused item is a valid Expression or a token that is an identifier.
Public propertyHasUnusedExpressionNonDirective
Returns true if the last Unused item is a valid Expression or a token that is an identifier, skipping over any compiler directives if a non-compiler directive exists.
Public propertyHasUnusedIdentifier
Returns true if the last Unused item is a Token which is an Identifier.
Public propertyHasUnusedModifiersOnly
Return true if the unused items are all modifiers (or annotations).
Public propertyHasUnusedToken
Returns true if the last Unused item is a Token.
Public propertyHasUnusedTypeRef
Return true if the last unused item is a TypeRef or possible TypeRef.
Public propertyHasUnusedTypeRefAndExpression
Return true if the last 2 unused items are a TypeRef or possible TypeRef followed by an Expression.
Public propertyHasUnusedTypeRefAndExpressionNonDirective
Return true if the last 2 unused items are a TypeRef or possible TypeRef followed by an Expression, skipping over any compiler directives.
Public propertyHasUnusedTypeRefAndIdentifier
Return true if the last 2 unused items are a TypeRef or possible TypeRef followed by an identifier.
Public propertyInDocComment
True if parsing a documentation comment.
Public propertyInEmbeddedExpression
True if parsing an embedded expression (such as inside an interpolated string).
Public propertyIsGenerated
True if parsing a generated file (such as '.g.cs' or '.Designer.cs'). Formatting and code cleanup settings will be ignored.
Public propertyIsGeneratedRegion
True if parsing a region of generated code (such as code from the MS Component Designer). Formatting and code cleanup settings will be ignored.
Public propertyLastPeekedToken
Get the last token that was returned by PeekNextToken().
Public propertyLastPeekedTokenText
Get the text of the last token that was returned by PeekNextToken().
Public propertyLastUnused
Get the last parsed object in the Unused list (Token or UnusedCodeObject).
Public propertyLastUnusedCodeObject
Get the last parsed object in the Unused list as a CodeObject (null if none, or not an UnusedCodeObject).
Public propertyLastUnusedToken
Get the last parsed object in the Unused list as a Token (null if none, or not a Token).
Public propertyLastUnusedTokenText
Get the text of the last parsed object in the Unused list as a Token (null if none).
Public propertyPeekChar
The character after the next character to be processed.
Public propertyToken
The current token.
Public propertyTokenLineNumber
Get the line number of the current token.
Top
Methods
  NameDescription
Public methodStatic memberAddCompilerDirectiveParsePoint
Add a parse-point for a compiler directive - triggers the callback when the specified token appears after the '#'.
Public methodStatic memberAddDocCommentParseTag
Add a documentation comment tag for callback during parsing.
Public methodStatic memberAddOperatorParsePoint(String, Int32, Boolean, Boolean, ParserParseDelegate)
Add a parse-point to the parser for an operator - the callback is triggered when the token is found.
Public methodStatic memberAddOperatorParsePoint(String, Int32, Int32, Boolean, Boolean, ParserParseDelegate, Type)
Add a parse-point to the parser for an operator - the callback is triggered when the token appears in the specified context.
Public methodStatic memberAddParsePoint(String, ParserParseDelegate)
Add a parse-point to the parser - the callback is triggered when the token is found.
Public methodStatic memberAddParsePoint(String, ParserParseDelegate, Type)
Add a parse-point to the parser - the callback is triggered when the token appears in the specified context.
Public methodStatic memberAddParsePoint(String, Int32, ParserParseDelegate)
Add a parse-point to the parser - the callback is triggered when the token is found.
Public methodStatic memberAddParsePoint(String, Int32, ParserParseDelegate, Type)
Add a parse-point to the parser - the callback is triggered when the token appears in the specified context.
Public methodAddUnused(CodeObject)
Add a code object that was just parsed but not yet needed to the unused list.
Public methodAddUnused(Token)
Add a token that was just parsed but not yet needed to the unused list.
Public methodAttachMessage
Create a parser error message in connection with the specified Token and attach it to the related CodeObject.
Protected methodCheckForUnusedTypeRef
Check that there appears to be an unused identifier, TypeRef, or UnresolvedRef at the specified offset.
Public methodCurrentTokenIndentedLessThan
Determine if the current token is indented less than the specified starting token.
Public methodDispose
Releases all resources used by the Parser
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetCurrentLine
Get the current line of text including the EOL character.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetIdentifier
Get the current token if it's an identifier, otherwise return null; also, advance to the next token.
Public methodGetIdentifierText
Get the text of the current token if it's an identifier, otherwise return null; also, advance to the next token. Does NOT return the '@' verbatim prefix if there was one.
Public methodGetLastPeekedTokenText
Get the previously peeked token text at the specified index (-1 is the last peeked token, -2 the one before that, etc).
Protected methodGetLastUnusedNonDirective
Get the last parsed object in the Unused list (Token or UnusedCodeObject), skipping over any compiler directives if a non-compiler directive exists.
Public methodGetNormalizationBlocker
Get the current normalization blocker object.
Public methodGetOperatorInfoForToken
Get the OperatorInfo structure for the current token.
Public methodGetToDelimiter
Parse from just after the current token up to (but not including) the specified delimiter, returning that as a string, and advancing to the delimiter as the next token. Stops just short of EOL if the delimiter isn't found. If the optional 'abortDelimiter' is non-zero, the string extraction will stop if it is encountered.
Public methodGetTokenToEOL
Parse from the current token up to (but not including) the EOL, returning that as a string, and advancing to the next token.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodGetUnused
Get the object in the Unused list at the specified index.
Public methodGetUnusedCodeObject
Get the object in the Unused list at the specified index as a CodeObject.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodStatic memberMergeTokens
Merge the specified 2nd token into the first one.
Public methodMoveCommentsToPostUnused
Move any non-EOL comments we just passed to the Post unused list.
Public methodMoveCommentsToUnused
Move any non-EOL comments we just passed to the unused list.
Public methodMovePostUnusedToUnused
Move the current post-unused list to the unused list.
Public methodMoveUnusedToPostUnused
Move the current unused list to the post-unused list.
Protected methodNextChar
Public methodNextToken
Get the next token, skipping comments (which are attached to the last token).
Public methodNextToken(Boolean)
Get the next token, optionally including comments.
Public methodNextTokenSameLine
Get the next token on the same line (including comments). Returns null if none.
Protected methodParseCharLiteral
Public methodParseCodeBlockUntil
Parse an embedded code block inside a documentation comment, starting with the current token, and parsing up to the specified delimiter.
Public methodParseCodeExpressionUntil
Parse an embedded code expression inside a documentation comment, starting with the current token, and parsing up to the specified delimiter.
Public methodParseEmbeddedExpressionUntil
Parse an embedded expression (such as inside an interpolated string), starting with the current token, and parsing up to the specified delimiter(s).
Protected methodParseInterpolatedString
Protected methodParseInterpolatedVerbatimString
Protected methodParseNextToken
Protected methodParseString
Protected methodParseVerbatimString
Public methodPeekNextToken
Peek ahead at the next unparsed token, skipping comments. Peek-ahead tokens are saved in a special queue so they are still processed by NextToken(). Returns null on EOF or if a compiler directive ('#') is encountered.
Public methodPeekNextTokenText
Peek at the next token, and return the text (avoids a null ref check).
Public methodPopNormalizationBlocker
Pop the last normalization blocker object.
Public methodPopUnusedList
Restore the previous Unused list.
Public methodProcessToken
Process the current token using the specified flags, returning a CodeObject if successful, otherwise returns null and the unrecognized token is saved in the Unused list for later.
Protected methodProcessTrailingComments
Public methodPushNormalizationBlocker
Push an object that will block EOL comment bubble-up normalization.
Public methodPushUnusedList
Push the current Unused list.
Public methodRemoveLastUnused
Remove the last object from the Unused list.
Public methodRemoveLastUnusedExpression
Remove the last object from the Unused list, converted to an Expression. Does NOT remove tokens that aren't valid identifiers.
Public methodRemoveLastUnusedExpression(Boolean)
Remove the last object from the Unused list, converted to an Expression.
Public methodRemoveLastUnusedToken
Remove the last object from the Unused list, IF it's a Token.
Public methodResetPeekAhead
Reset the peek ahead queue index.
Public methodSaveAndNextToken
Save the current token in the Unused list, and get the next one.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodTrackConditionalDirective
Track multi-part compiler directives.
Public methodTrackEndRegionDirective
Track an EndRegionDirective, returning any related RegionDirective.
Public methodTrackRegionDirective
Track a RegionDirective.
Public methodUnpeek
Unpeek the specified number of tokens.
Public methodUsingMoreTabsThanSpaces
Returns true if more lines in the parsed file start with tabs than spaces.
Top
Fields
  NameDescription
Protected field_ch
Protected field_conditionalNestingLevelStack
Protected field_isSLOC
Protected field_length
Protected field_line
Protected field_linesWithSpaces
Protected field_linesWithTabs
Protected field_normalizationBlockerStack
Protected field_peekAheadIndex
Protected field_peekAheadTokens
Protected field_pk
Protected field_pos
Protected field_previous
Protected field_start
Protected field_startLine
Protected field_textReader
Protected field_token
Protected field_unusedListStack
Protected field_wasEscaped
Public fieldCodeUnit
The CodeUnit being parsed.
Public fieldConditionalNestingLevel
The current nesting level if parsing the '?' clause of a Conditional expression.
Public fieldInDirectiveExpression
True if parsing a compiler directive expression.
Public fieldLastToken
The last token.
Public fieldLineNumber
The current line number.
Public fieldParentStartingToken
The starting token of the last parent code object.
Public fieldParseFlags
Global parsing flags.
Public fieldPostUnused
Special-case Unused objects after the current code object instead of before it.
Public fieldSingleUnusedIdentifierParser
Delegate for parsing single unused identifiers in Blocks (used for EnumDecls).
Public fieldStatic memberSkipToken
Special object used to skip processing of a token.
Public fieldSLOC
SLOC count: Lines with other than blanks, comments, symbols (such as braces).
Public fieldTerminatingKeywords
Optional keywords that should terminate the current parsing if encountered (used for things such as context-sensitive keywords within LINQ queries).
Public fieldTokenText
The text of the current token (null if none).
Public fieldTokenType
The type of the current token (None if none).
Public fieldUnused
Unused tokens or code objects in the current active scope.
Top
Remarks
Code objects have the ability to parse themselves from text, but they use this class to help them do it. An instance of this class is created for each file (or chunk of text) being parsed, and it tokenizes the text and calls back to the logic in the code objects via registered "parse-points".
See Also