-
Notifications
You must be signed in to change notification settings - Fork 300
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
Refactored and Optimized Logic:: Parser Logic & Shared Modules #283
Conversation
Hi @aswaterman and @rpsene, I have made an attempt to refactor the The test cases are failing as we need to modify the Requesting feedback on the modified code and suggestions on what best we can do to achieve maintainability and scalability. |
Hi @aswaterman, in addition to the written explanation of the parsing logic inside "Flow of Like, we have three main steps with each having sequence of procedures: flowchart TD
A[Start: parse.py] --> B[Create list of all rv* files]
B --> C{File contains regular instructions?}
C -->|Yes| D[Parse file line by line]
D --> E[Perform checks on regular instructions]
E --> F[Check 1: msb > lsb in range assignment]
E --> G[Check 2: Value representable in range]
E --> H[Check 3: No multiple assignments to same bit]
E --> I[Check 4: All bit positions must be accounted for]
F --> J[Pass checks?]
G --> J
H --> J
I --> J
J -->|Yes| K[Create dictionary for regular instruction]
K --> L[Add encoding, extension, mask, match, variable_fields]
L --> M[Add to instr_dict]
M --> N[Process next regular instruction]
N -->|All regular instructions processed| O[End of Regular Instruction Parsing]
|
2. In the second pass, we do the checks for pseudo_instr carrying out similar procedure. 3. In the last step, the output generation, flowchart TD
A[Start Output Generation] --> B[Generate LaTeX tables]
B --> C[Generate encoding.h file]
C --> D[Generate other artifacts]
D --> E[Output files generated]
E --> F[End]
|
@aswaterman and @rpsene , These flowchart creation process are markdown friendly. I think it will also help to give a nutshell view of what we are doing. Let me know the feedback and suggestions, if these will add up to an enhancement for the existing repository. |
@aswaterman and @rpsene , Refactored and Optimized the method used for creating instruction dictionary. P.S. The second point from Needs to be Done header in PR description is ticked(marked as completed) as of now |
The conflicts arises as after the commit w.r.t walrus operator made in @aswaterman, the walrus operator (:=) is compatible with Python 3.8 and later versions, as it was introduced in Python 3.8, and it allows assignment within an expression, making it useful for situations where we want to assign and evaluate a variable in the same line. So, wanted to know, whether we need to keep in mind with older versions compatibility of Python while doing refactorization and optimization. |
I'll try to provide feedback on this PR soon. To answer the immediate question: if we have good reason to start making extensive use of newer Python features, I have no objections to upgrading, but I did not think that a single use of the walrus operator was a sufficient justification for requiring a newer Python version. |
Signed-off-by: Jay Dev Jha <jaydev.neuroscitech@gmail.com>
Yes, I do agree with this. While going through the files in this repository, I found that the |
You've convinced me that other new features are a good enough justification to move to 3.8. |
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.
Very reasonable refactoring. I presume at this point there will be some merge conflicts with respect to other recent changes to the master branch, but feel free to merge once you've resolved them.
Signed-off-by: Jay Dev Jha <jaydev.neuroscitech@gmail.com>
Signed-off-by: Jay Dev Jha <jaydev.neuroscitech@gmail.com>
@aswaterman and @rpsene , Cleaned up the codes for parsing logic. I am only keeping the shared methods/ functions in the Will raise separate PR(s) for supporting refactorization and modularization of each dedicated scripts in very near time, as this will not only help in review smaller PRs but will also help to debug later in the future. These would be as VIZ:
Just giving a final check before merging, matching the generated outputs with this approach and those that were generated earlier with existing codes. I have also verified this logic and modular approach with optimized techniques, on applying generating |
Signed-off-by: Jay Dev Jha <jaydev.neuroscitech@gmail.com>
@aswaterman revised the PR with updated code regarding to the newer latest PR #303. Merging it now. |
@IIITM-Jay thank you! |
This PR intends to refactor the parse.py to achieve maintainability and scalability.
Scopes Covered
Approach Followed
parse.py
file now contains only the main function where it calls respective scripts for generating the output based on extensions selected.shared_utils.py
so that other scripts can re-use them efficiently. These functions are shared between various extension scriptsLatex
is refactored and optimized inlarex_utils.py
parse.py
andshared_utils.py
are refactored, modularized and optimized as wellNeeds to be done
parse.py
to their modules likec_utils.py
for generating c based outputshared_utils.py
, the methodcreate_inst_dict()
is yet to be refactored.