-
Notifications
You must be signed in to change notification settings - Fork 30
Add ParseBehavior to parser settings #393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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
, andParseSection
- Removes
readDocument
method from parser interfaces and implements the behavior inparseUtils
- 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 toparseResult
ortriedParseResult
for better clarity.
const result: TriedParse = updatedSettings.parserEntryPoint
Co-authored-by: Copilot <[email protected]>
…/powerquery-parser into dev/jobolton/parseMode
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 intoparseUtils