Search notes:

System.Management.Automation.Language.Parser (class)

System.Management.Automation.Language.Parser has two (three) methods to parse PowerShell scripts and expressions.
These methods return a System.Management.Automation.Language.ScriptBlockAst object.
The names of the two methods are

Get the tokens of a piece of code

set-strictMode -version 3

[System.Management.Automation.Language.Token[]     ] $tokens = $null
[System.Management.Automation.Language.ParseError[]] $errors = $null

$code = @'
$x = 2; $y = 4
$res = $x + $y
write-host "result = $res"
'@

$ast = $null = [System.Management.Automation.Language.Parser]::ParseInput(
        $code,
  [ref] $tokens,
  [ref] $errors
)

foreach ($token in $tokens) {

   $text = $token.Text -replace "`n", '<CR>'

#  write-host ($token.TokenFlags)
   write-host ('  {0,-30} {1}' -f $text, $token.Kind)
}
#
#  $x                             Variable
#  =                              Equals
#  2                              Number
#  ;                              Semi
#  $y                             Variable
#  =                              Equals
#  4                              Number
#  <CR>                           NewLine
#  $res                           Variable
#  =                              Equals
#  $x                             Variable
#  +                              Plus
#  $y                             Variable
#  <CR>                           NewLine
#  write-host                     Generic
#  "result = $res"                StringExpandable
#                                 EndOfInput
Github repository .NET-API, path: /System/Management/Automation/Language/Parser/get-tokens.ps1

See also

PowerShell: Parsing commands and expressions

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Microsof...', 1745418479, '160.79.108.182', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Microsoft/dot-net/namespaces-classes/System/Management/Automation/Language/Parser/index(92): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78