PSParser.Tokenize Method

Definition

Overloads

Tokenize(Object[], Collection<PSParseError>)

Parse a script into a collection of tokens.

Tokenize(String, Collection<PSParseError>)

Parse a script into a collection of tokens.

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);
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.Mnagement.Automation.RuntimeException but may contain an inner exception that describes the real issue.

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);
Parameters
script
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.Mnagement.Automation.RuntimeException but may contain an inner exception that describes the real issue.