Powershell 5 parser



  • I was working on a project that utilised Powershell 5 classes. I made this modification to my functionList.xml. I jumbly submit it here for those it may help (and for anyone that has improvements)

    <!-- ================================================== [ PowerShell 5 ] -->
    
    			<parser
    				displayName="PowerShell"
    				id         ="powershell_syntax"
    				commentExpr="(?x)                                               # Utilize inline comments (see `RegEx - Pattern Modifiers`)
    								(?s:\x3C\x23(?:[^\x23]|\x23[^\x3E])*\x23\x3E)   # Multi Line Comment
    							|	(?m-s:\x23.*$)                                  # Single Line Comment
    							"
    			>
                    <classRange
    					mainExpr    ="(?ms)class\s+[A-Za-z_0-9\-]+[^{]*({(((?>[^{}]+)|(?1))*)})"
    
    				>
    					<className>
    						<nameExpr expr="(?:class\s+)([^{]*)" />
    					</className>
    					<function
    						mainExpr="(?xmi)(?:\[[A-Za-z:\.[\]]*])
    							\s*
    							[A-Za-z_\-]+
    							[^{]+"
    					>
    						<functionName>
    							<funcNameExpr expr=".*" />
    						</functionName>
    					</function>
    				</classRange>            
                
    				<function
    					mainExpr="(?xmi)(?:function|filter)
    							\s*
    							[A-Za-z_\-]+							
    							[^{]+
    						"
    				>
    					<functionName>
    						<nameExpr expr="(?i)[A-Za-z_\-]*\s*[^{]+" />
    					</functionName>
    				</function>
    			</parser>
    

Log in to reply