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, as an array of lines</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(object[] script, out Collection<PSParseError> errors)
        {
            if (script == null)
                throw PSTraceSource.NewArgumentNullException("script");
            StringBuilder sb = new StringBuilder();
            foreach (object obj in script)
            {
                if (obj != null)
                {
                    sb.AppendLine(obj.ToString());
                }
            }
            return Tokenize(sb.ToString(), out errors);
        }
public static Collection < PSToken > Tokenize ( object [ ] script , out Collection < PSParseError > errors ) { if ( script == null ) throw PSTraceSource . NewArgumentNullException ( " " ) ; StringBuilder sb = new StringBuilder ( ) ; foreach ( object obj in script ) { if ( obj != null ) { sb . AppendLine ( obj . ToString ( ) ) ; } } return Tokenize ( sb . ToString ( ) , out errors ) ; }
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
object[]
script to parse, as an array of lines
script to parse as an array of lines
Collection<PSParseError>
out
errors
errors happened during parsing
errors happened during parsing