Skip to content

Commit

Permalink
Reimplement PowerShell lexer (#1213)
Browse files Browse the repository at this point in the history
The existing PowerShell lexer subclasses the Shell lexer and
extends/modifies its rules. However, while PowerShell is a shell, its
syntax and grammar is far richer than other shells. This commit replaces
the existing lexer with a new lexer that is independent of the Shell lexer.
  • Loading branch information
aaroneg authored and pyrmont committed Jun 28, 2019
1 parent 904afdc commit f1125f3
Show file tree
Hide file tree
Showing 3 changed files with 352 additions and 721 deletions.
60 changes: 12 additions & 48 deletions lib/rouge/demos/powershell
Original file line number Diff line number Diff line change
@@ -1,49 +1,13 @@
Function Get-IPv4Scopes
<#
.SYNOPSIS
Read IPv4Scopes from an array of servers
.PARAMETER Servers
Specifies an array of servers
.EXAMPLE
Get-IPv4Scopes

Will prompt for all inputs
#>
function Verb-Noun
{
[CmdletBinding()]
Param(
# 1
[parameter(
Mandatory=$true,
Position=0,
ValueFromPipelineByPropertyName=$true,
HelpMessage="Server List"
)]
[string[]]$Servers,
#2
[parameter(Mandatory=$false,ValueFromPipeline=$false)]
[bool]$Unique=$false
) #EndParam

Begin {}

Process {
$arrayJobs=@()
foreach ($server in $Servers) {
$arrayJobs+=Invoke-Command -ComputerName $server -scriptblock {Get-DhcpServerv4Scope} -AsJob
}
$complete=$false
while (-not $complete) {
$arrayJobsInProgress= $arrayJobs | Where-Object { $_.State -match 'running' }
if (-not $arrayJobsInProgress) { $complete=$true }
}
$Scopes=$arrayJobs|Receive-Job
$UniqueScopes=$Scopes|Sort-Object -Property ScopeId -Unique
}

End {
if ($Unique) { return $UniqueScopes }
else { return $Scopes }
}

} #end function
<#
.SYNOPSIS
Tells you what it does

.DESCRIPTION
Tells you what it does with more detail.
#>
param ([string]$Name, [string]$Extension = "txt", [string]$foo="bar")
$name = $name + "." + $extension
$name
}
Loading

0 comments on commit f1125f3

Please sign in to comment.