Skip to content

Conversation

JordanBoltonMN
Copy link
Contributor

@JordanBoltonMN JordanBoltonMN commented Aug 4, 2025

Adds the new setting ParseBehavior which limits what context the parser operates under. It can either look explicitly for a section document, or explicitly a expression document, or allow parsing of either.

Simplifies the "either or" behavior by moving it out of the IParser and into parseUtils

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds the new ParseBehavior setting to control whether the parser operates under section document context, expression document context, or allows parsing of either. This simplifies the parser architecture by removing the "either or" behavior from the IParser interface and moving it to parseUtils.

Key changes:

  • Introduces ParseBehavior enum with three modes: ParseEitherExpressionOrSection, ParseExpression, and ParseSection
  • Removes readDocument method from parser interfaces and implements the behavior in parseUtils
  • Refactors test utilities into a shared module for better maintainability

Reviewed Changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/powerquery-parser/parser/parseBehavior.ts Defines the new ParseBehavior enum
src/powerquery-parser/parser/parseSettings.ts Adds parseBehavior to ParseSettings interface
src/powerquery-parser/settings.ts Updates DefaultSettings to include parseBehavior
src/powerquery-parser/parser/parseState/*.ts Adds parseBehavior to ParseState interface
src/powerquery-parser/parser/parser/parserUtils.ts Implements document parsing logic with ParseBehavior support
src/powerquery-parser/parser/parser/parser.ts Removes readDocument from Parser interface
src/powerquery-parser/parser/parsers/*.ts Removes readDocument implementations
src/test/libraryTest/parser/parserTestUtils.ts Extracts shared test utilities
src/test/libraryTest/parser/parseSimple.test.ts Refactors to use shared test utilities
src/test/libraryTest/parser/parseBehavior.test.ts Adds tests for the new ParseBehavior functionality
package.json Version bump to 0.17.0
Comments suppressed due to low confidence (1)

src/powerquery-parser/parser/parser/parserUtils.ts:27

  • [nitpick] The variable name result is generic. Consider renaming it to parseResult or triedParseResult for better clarity.
    const result: TriedParse = updatedSettings.parserEntryPoint

@JordanBoltonMN JordanBoltonMN merged commit 98cbf98 into master Aug 7, 2025
4 checks passed
@JordanBoltonMN JordanBoltonMN deleted the dev/jobolton/parseMode branch August 7, 2025 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants