Add ParseExpr function to parser package #9
+383
−206
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The parser package lacked a direct way to parse standalone expressions—only ClassAds could be parsed via
ParseClassAd.Changes
startrule to acceptexprin addition toclassad, allowing bare expressions like2 + 3to parse successfullyParseExpr(input string) (ast.Expr, error)for expression-only parsingParseto clarify it accepts both ClassAds and expressions; updatedParseClassAdto note it rejects non-ClassAd inputParseClassAdto return descriptive errors (e.g.,"parsed input is not a ClassAd, got *ast.BinaryOp") instead of(nil, nil)Usage
Note: Grammar now has 2 reduce/reduce conflicts due to ambiguity between
classadandexprfor record literals like[a = 1]. The parser resolves this correctly by preferring the first production (classad).Original prompt
parserpackage #8✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.