Skip to content

Extract shared native argument fragment classification #69

Description

@Aaronontheweb

Problem

PR #68 added equivalent native-argument fragment walks to the Bash and PowerShell parsers. Both implementations now collect contiguous lexer fragments, preserve the complete raw span and decoded value, detect opaque fragments, and safe-fail resolver-sensitive mixed quoting. Keeping those rules duplicated creates a drift risk when another fragment shape or shell is added.

This is not a request for a shared lexer or parser core. Bash and PowerShell must retain their shell-specific tokenization, quoting, recursion, and command semantics.

Proposed scope

Extract an internal shell-neutral classification result for one native argument assembled from parser-owned lexer fragments. Each parser adapts its own tokens into the helper and remains responsible for consuming the resulting token range.

The shared result should carry:

  • the complete authored source span and raw value;
  • the combined decoded logical value;
  • whether any fragment is opaque or computed;
  • whether all value fragments are literal;
  • whether mixed literal and expandable fragments contain resolver-sensitive syntax;
  • the first index after the consumed fragment run.

Non-goals

  • Unifying the Bash and PowerShell lexers.
  • Building a shared parser base class.
  • Changing the public AST or parser APIs.
  • Weakening DynamicSkip behavior for ambiguous mixed quoting.

Acceptance criteria

  • Bash and PowerShell use one internal fragment-classification implementation.
  • Shell-specific token adapters remain small and explicit.
  • Existing Raw, Value, source-span, path, and DynamicSkip behavior remains unchanged.
  • The PR Preserve source-ordered clause elements for issue #62 #68 adversarial corpus cases for quoted values, maximal fragment runs, unquoted prefixes, mixed literal syntax, and curl @ transformation remain green in both shells.
  • dotnet build -c Release, dotnet test -c Release, and header verification pass.

Extraction trigger

Do this before adding a third shell or another native fragment rule. Until then, the current duplication is correct but carries maintenance cost.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions