pub enum Token {
StringExpandable(String, String),
String(String),
Expression(String, PsValue),
Function(String, String, Vec<PsValue>),
}
Expand description
Represents a parsed token from a PowerShell script.
Tokens are the building blocks of parsed PowerShell code and are used for syntax analysis, deobfuscation, and code transformation.
Right now 4 token types are supported:
- String: Representation of single quoted PowerShell strings (e.g.,
'hello world'
) - StringExpandable: Representation of double quoted PowerShell strings
with variable expansion (e.g.,
"Hello $name"
) - Expression: Parsed PowerShell expressions with their evaluated results
(e.g.,
$a + $b
) - Function: PowerShell function definitions and calls
Each token type stores both the original source code and its processed/evaluated form, making it useful for deobfuscation and analysis purposes.
§Examples
use ps_parser::PowerShellSession;
let mut session = PowerShellSession::new();
let script_result = session.parse_input("$var = 123").unwrap();
// Inspect the tokens
for token in script_result.tokens().all() {
println!("Token: {:?}", token);
}
Variants§
StringExpandable(String, String)
String(String)
Expression(String, PsValue)
Function(String, String, Vec<PsValue>)
Trait Implementations§
impl StructuralPartialEq for Token
Auto Trait Implementations§
impl Freeze for Token
impl RefUnwindSafe for Token
impl Send for Token
impl Sync for Token
impl Unpin for Token
impl UnwindSafe for Token
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more