给定一个 powershell 脚本(例如 $C=$a+$b; $d = $e*$f),我尝试访问脚本 AST 中的每个节点。
\n\n目前,我\xe2\x80\x99已经尝试过:
\n\n$code = {$C=$a+$b; $d = $e*$f}\n$astVisitor = [System.Management.Automation.Language.AstVisitor]\n$visit = $code.Ast.Visit($astVisitor)\nRun Code Online (Sandbox Code Playgroud)\n\nbut I\xe2\x80\x99m running into the following error: Cannot find an overload for "Visit" and the argument count: "1".
\n\nWhat\'s the right way to access the ast data structure and use the visit method correctly to loop through every node in the tree? I didn\'t find the documentation of the ast api very helpful.
\n\nThanks very …