src/System.Management.Automation/engine/lang/interface/PSParser.cs
/// <summary>
/// Parse a script into a collection of tokens. 
/// </summary>
/// <param name="script">script to parse</param>
/// <param name="errors">errors happened during parsing</param>
/// <returns>collection of tokens generated during parsing</returns>
/// <exception cref="System.Management.Automation.RuntimeException">
/// 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.
/// </exception>
Parse a script into a collection of tokens.
Parse a script into a collection of tokens .
public static Collection<PSToken> Tokenize(string script, out Collection<PSParseError> errors)
        {
            if (script == null)
                throw PSTraceSource.NewArgumentNullException("script");
            PSParser psParser = new PSParser();
            psParser.Parse(script);
            errors = psParser.Errors;
            return psParser.Tokens;
        }
public static Collection < PSToken > Tokenize ( string script , out Collection < PSParseError > errors ) { if ( script == null ) throw PSTraceSource . NewArgumentNullException ( " " ) ; PSParser psParser = new PSParser ( ) ; psParser . Parse ( script ) ; errors = psParser . Errors ; return psParser . Tokens ; }
Parse a script into a collection of tokens.
Parse a script into a collection of tokens .
collection of tokens generated during parsing
collection of tokens generated during parsing
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.
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 .
script
string
script to parse
script to parse
Collection<PSParseError>
out
errors
errors happened during parsing
errors happened during parsing