Appendix C. The PowerShell grammar

One way to learn a new language is to look at its grammar. This appendix presents the PowerShell grammar annotated with notes and examples to help explain what’s happening.

PowerShell is parsed using an augmented recursive descent parser. The augmentations are needed to deal with some of the complexities in tokenizing the PowerShell language. This topic is discussed in more detail in chapter 2.

The complete parser is composed of a set of parsing rules and tokenizing rules. These parsing and tokenization rules are what we’re covering in this appendix. These rules can be separated into five layers:

  1. Statement list: the rules for parsing a basic statement list and a statement block.

  2. Statements: various kinds of statements ...

Get Windows PowerShell in Action now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.