小编Gil*_*sak的帖子

从 Powershell 脚本中提取 AST

给定一个 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)\n
Run Code Online (Sandbox Code Playgroud)\n\n

but I\xe2\x80\x99m running into the following error: Cannot find an overload for "Visit" and the argument count: "1".

\n\n

What\'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\n

Thanks very …

powershell abstract-syntax-tree

3
推荐指数
1
解决办法
1094
查看次数

标签 统计

abstract-syntax-tree ×1

powershell ×1