This repository was archived by the owner on Apr 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Deduplicate productions #505
Merged
Merged
Changes from 3 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
f31eae5
Deduplicate productions
virgil-serbanuta ddd977c
Merge f31eae567ce0b05f32cb1233f299f6f692615d2c into be262783d22ac29ab…
virgil-serbanuta 635df4c
Set Version: 0.1.340
rv-auditor 7412737
Fix review comments
virgil-serbanuta e822ed3
Merge branch 'master' into fix-deduplicate-productions
virgil-serbanuta 39c89c6
Merge e822ed3530627b7c4e2def364878784f23da7cd1 into 606bd702c6077fd7b…
virgil-serbanuta a16e92b
Set Version: 0.1.341
rv-auditor 719126d
Add test
virgil-serbanuta 9a3555e
Fix review comments
virgil-serbanuta 541ae86
Merge branch 'master' into fix-deduplicate-productions
virgil-serbanuta c823246
Merge 541ae86abb72b35e2ef8995250779e9c1bb3b79d into b596b753413203160…
virgil-serbanuta e323c29
Set Version: 0.1.343
rv-auditor 2b8a459
Fix review comments
virgil-serbanuta d6f5762
Update src/pyk/kast/kast.py
virgil-serbanuta 9ee428d
Merge branch 'master' into fix-deduplicate-productions
virgil-serbanuta 0b24257
Merge 9ee428d28ebdf6b9b78080eb853f2b482a1f97fc into e0cb46765b33f27a8…
virgil-serbanuta 9e12943
Set Version: 0.1.345
rv-auditor c836e9d
Fix review comments.
virgil-serbanuta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 0.1.339 | ||
| 0.1.340 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" | |
|
|
||
| [tool.poetry] | ||
| name = "pyk" | ||
| version = "0.1.339" | ||
| version = "0.1.340" | ||
| description = "" | ||
| authors = [ | ||
| "Runtime Verification, Inc. <[email protected]>", | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1033,6 +1033,23 @@ def production_for_klabel(self, klabel: KLabel) -> KProduction: | |
| _LOGGER.warning( | ||
| f'Discarding {len(prods) - len(_prods)} productions with `unparseAvoid` attribute for label: {klabel}' | ||
| ) | ||
| # Automatically defined symbols like isInt may get multiple | ||
| # definitions in different modules. | ||
| unique_no_att: list[tuple[KProduction, KProduction]] = [] | ||
| for prod in prods: | ||
| equivalent = False | ||
| trimmed_prod = prod.let_att(KAtt({})) | ||
| for _, t in unique_no_att: | ||
| if t == trimmed_prod: | ||
| equivalent = True | ||
| break | ||
| if equivalent: | ||
| continue | ||
| unique_no_att.append((prod, trimmed_prod)) | ||
| _prods = [p for p, _ in unique_no_att] | ||
tothtamas28 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if len(_prods) < len(prods): | ||
| prods = _prods | ||
| _LOGGER.warning(f'Discarding {len(prods) - len(_prods)} equivalent productions') | ||
|
||
| try: | ||
| self._production_for_klabel[klabel] = single(prods) | ||
| except ValueError as err: | ||
|
|
||
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.
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.
After fixing
_freeze, aCounter-base solution should work (not thoroughly tested):This version always returns a production without source map. If retaining it is important (in the case whe there is a single production), a
dict-based variant can be implemented with.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.
Done.