-
Notifications
You must be signed in to change notification settings - Fork 0
Normalise selectors in plan synthesiser and verifier #3
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,13 +64,20 @@ def _extract_selectors(self, context: Optional[dict]) -> Sequence[str]: | |
|
|
||
| def _plan_compatible(self, node: DSLNode, selectors: Sequence[str]) -> bool: | ||
| if node.verb in {DSLVerb.CLICK, DSLVerb.TYPE} and node.args: | ||
| selector = node.args[0] | ||
| selector = self._normalise_selector(node.args[0]) | ||
| if selector and selectors and selector not in selectors: | ||
| return False | ||
| for child in node.children: | ||
| if not self._plan_compatible(child, selectors): | ||
| return False | ||
| return True | ||
|
|
||
| @staticmethod | ||
| def _normalise_selector(raw_selector: str) -> str: | ||
| token = raw_selector.split(",", 1)[0].strip() | ||
| token = token.rstrip(")").strip() | ||
| token = token.strip("\"'") | ||
|
Comment on lines
+75
to
+79
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The normaliser now calls Useful? React with 👍 / 👎. |
||
| return token | ||
|
|
||
|
|
||
| __all__ = ["Sketch", "CandidatePlan", "PlanSynthesiser"] | ||
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.
When
_handle_plan_sketchsplitsarg_strby","it does not consider quoting, so a token such asType(#field, "hello, world")producesargs = ["#field", "hello", "world"]instead of keeping the comma inside the second argument. Any plan where argument values legitimately contain commas or closing parentheses will now be broken and the original string cannot be reconstructed. Using a parsing approach that honours quoted strings or balanced parentheses would avoid fragmenting arguments.Useful? React with 👍 / 👎.