Skip to content

Conversation

@michaelblyons
Copy link
Collaborator

@michaelblyons michaelblyons commented Dec 5, 2025

Please test if you are so inclined! I originally set out to pull expressions apart from a new statements context, but it's gone a lot further than that, now.

New

  • Grouping of syntax rules within the file
  • Fully-recognized command expressions (i.e. no longer require Verb-Noun because we know it must be a command)
    This is the most likely place to find bugs.
  • Classes have full body scope
  • Functions have full body scope
  • Desired State Configuration (DSC) contexts
  • Workflow contexts
  • Embed C# in here-strings if a couple common patterns are detected
  • True/False/Null get extended scopes
  • String format placeholders (Thanks to @deathaxe for the non-lazy approach)
  • Wildcard and path characters in unquoted strings following commands
  • Regex in single-quoted strings after -match and -replace operators

Changed

  • Many context names are pluralized, indicating that they will match multiple occurrences of their matches
  • A new statements context restricts some contexts that were being nested everywhere.
    This is the second most likely place to find bugs.
  • Types have been sorted into builtin aliases (some may be missing) and formal types
  • using imports can now only come at the top of the file, as the docs specify.
  • Variables can now be named according to the insane official support.
  • Strings can be quoted with curly quotes if you're a masochist.

Maybe

  • Better wildcard scoping
  • Context-aware flow controls
  • Extend the default RegExp syntax (once each for single and double quoted strings?) to tune the regex flavor and add interpolations to double quoted strings

@michaelblyons
Copy link
Collaborator Author

@matteocoder Do you want to give this a try? Let me know if there are big regressions.

@michaelblyons michaelblyons force-pushed the refactor branch 3 times, most recently from 1a7dc0b to d56121f Compare December 8, 2025 20:30
@michaelblyons michaelblyons marked this pull request as ready for review December 8, 2025 20:33
@michaelblyons michaelblyons linked an issue Dec 9, 2025 that may be closed by this pull request
@michaelblyons michaelblyons added this to the 5.0.0 milestone Dec 9, 2025
@michaelblyons michaelblyons linked an issue Dec 9, 2025 that may be closed by this pull request
@michaelblyons michaelblyons linked an issue Dec 9, 2025 that may be closed by this pull request
@matteocoder
Copy link
Contributor

@michaelblyons I apologise for the late reply! Life got in the way. I checked with my usual PowerShell files, and it looks good to me.

michaelblyons and others added 9 commits December 11, 2025 09:12
This commit ...

1. ensures balanced braces within unquoted strings
2. ensures string termination if parentheses or closing brace is matched
1. don't trigger within comments
2. trigger only directly after `@` character, as otherwise typing quotation
   mark after `@foo` would also trigger the chain command.
3. trigger only if not directly followed by corresponding quotation or at-sign.
This commit...

1. separates double- and single-quoted format string contexts to enable
   quotation marks in format-strings.
2. scopes format-spec as python
3. restricts format placeholders to brace+digit `{\d+}` to avoid false positives
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment