PSParser.Tokenize PSParser.Tokenize PSParser.Tokenize Method

Definition

Overloads

Tokenize(Object[], Collection<PSParseError>) Tokenize(Object[], Collection<PSParseError>) Tokenize(Object[], Collection<PSParseError>)

Parse a script into a collection of tokens.

Tokenize(String, Collection<PSParseError>) Tokenize(String, Collection<PSParseError>) Tokenize(String, Collection<PSParseError>)

Parse a script into a collection of tokens.

Tokenize(Object[], Collection<PSParseError>) Tokenize(Object[], Collection<PSParseError>) Tokenize(Object[], Collection<PSParseError>)

Parse a script into a collection of tokens.

public static System.Collections.ObjectModel.Collection<System.Management.Automation.PSToken> Tokenize (object[] script, out System.Collections.ObjectModel.Collection<System.Management.Automation.PSParseError> errors);
static member Tokenize : obj[] *  -> System.Collections.ObjectModel.Collection<System.Management.Automation.PSToken>
Public Shared Function Tokenize (script As Object(), ByRef errors As Collection(Of PSParseError)) As Collection(Of PSToken)
Parameters
script
Object[]

script to parse, as an array of lines

errors
Collection<PSParseError>

errors happened during parsing

Returns

collection of tokens generated during parsing

Exceptions

Although this API returns most parse-time exceptions in the errors collection, there are some scenarios where resource limits will result in an exception being thrown by this API. This allows the caller to distinguish between a successful parse with errors and a failed parse. All exceptions thrown will be derived from System.Management.Automation.RuntimeException but may contain an inner exception that describes the real issue.

Tokenize(String, Collection<PSParseError>) Tokenize(String, Collection<PSParseError>) Tokenize(String, Collection<PSParseError>)

Parse a script into a collection of tokens.

public static System.Collections.ObjectModel.Collection<System.Management.Automation.PSToken> Tokenize (string script, out System.Collections.ObjectModel.Collection<System.Management.Automation.PSParseError> errors);
static member Tokenize : string *  -> System.Collections.ObjectModel.Collection<System.Management.Automation.PSToken>
Public Shared Function Tokenize (script As String, ByRef errors As Collection(Of PSParseError)) As Collection(Of PSToken)
Parameters
script
String String String

script to parse

errors
Collection<PSParseError>

errors happened during parsing

Returns

collection of tokens generated during parsing

Exceptions

Although this API returns most parse-time exceptions in the errors collection, there are some scenarios where resource limits will result in an exception being thrown by this API. This allows the caller to distinguish between a successful parse with errors and a failed parse. All exceptions thrown will be derived from System.Management.Automation.RuntimeException but may contain an inner exception that describes the real issue.

Applies to