Topics: Developer Forum
Mar 12, 2007 at 3:18 PM
Do you guys have any experience with parsers? Keith pointed me to the intellisense for PowerShell by Aaron Lerch I am working on something similar for our tabexpansion. However, the TabExpansion $lastWord $line approach is very limited. How hard do you think would be to create a PS1 parser, which would call out to the popup form with the unparsed text and the current state (InVariableName, InCmdletCall, etc)...? That way, we'd be able to simulate Visual Studio auto complete quite closely.
Mar 12, 2007 at 5:14 PM
Edited Mar 12, 2007 at 7:38 PM
I've never written a full parser in my life man, but I've read about the academic concepts and my regex (and therefore understanding of automata in general) is excellent due to my spending 6 months datamining with it a few years ago.

If we're going to do this -- which sounds like a very ambitious but extremely exiciting -- idea, I think we should check out some free parsers out there - I did play with the GOLD parser before (which works with LALR and DFA constructs), and there is an immense amount of grammars out there for it already. Also, there's a free chapter of Bruce Payette's new book with a much better powershell grammar outline, see

In short, I'm in!

WRT the popup form, I take it that's an inline extended ascii popup, much like the current F7 history with the console host? I'd prefer not to use a winforms control, it kind goes against the command line spirit and breaks stuff like the powershell remoting project.

edit: available c# gold engines

edit: clarified ascii versus winforms
Mar 12, 2007 at 8:50 PM
I have started with a WinForm popup. We can implement both, using the WinForm in the console host and falling back to ASCII art otherwise. However the ASCII-based is harder to implement and the user experience is worse (no icons, scrolling is hard, ...) Moreover, the current UI-level remoting project is hardly a long-term solution. Microsoft is going to implement runspace remoting in the next version...
Apr 1, 2007 at 11:54 PM
Edited Apr 1, 2007 at 11:54 PM
Sorry, I found this discussion a few weeks late -- if you're wondering about my (deficient) intellisense for powershell , I just tacked a UI on top of MoW's tab expansion extensions: PowerTab

So I didn't implement any parsing what-so-ever. :)
Apr 9, 2007 at 4:59 AM
I talked to one PowerShell dev at the MVP summit who said a recursive descent parser is probably the way to do this. I don't believe the grammer is context free. I have a bit of experience doing reursive descent parsers. One problem we run into though is how to access previous lines in a multiline command? I also heard from another PowerShell MVP that his company had developed a PowerShell parser and it was a, uh, challenge (not exactly his wording). :-)