Skip to content
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

Add suppot for CSV input #34

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Add suppot for CSV input #34

wants to merge 4 commits into from

Conversation

cooki35
Copy link

@cooki35 cooki35 commented Nov 29, 2022

Add support for CSV like input and do some minor refactoring, also update the README.

Add the input format InputFormat.CSV in parse_lines. In parse_line call the function parse_line_csv if the input format is InputFormat.CSV. The parse_line_csv function extracts the instruction from the line and generates an Instruction instance.
Creat an abstract base class TargetInfo for the X86 and ARM target infos.
Make the class InputFormat inherit from Enum.
Move the classes to the top of the file.
Add some comments to document the code.
@Kazhuu
Copy link
Owner

Kazhuu commented Nov 30, 2022

Nice to see some improvements, also in the readme. Thanks! At quick glance the PR looks very solid, but I'll give this a thorough review after I'm not so busy with work. Some tests for CSV would be nice to have though. Also, where this CSV input is coming from?

Copy link
Owner

@Kazhuu Kazhuu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good work and thank you a lot for contributing! Would you add some minimal tests for CVS input? Also in the readme mentioning where the CVS input is coming from and how to obtain one would be good information to have in my opinion :)


def parse_function_header(line):
"""
Return function name of memory range from the given string line.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment does not match to what the function is actually returning anymore. This was already here before this PR, so I can also update these after this is merged.

elements: list[str] = line.split(';')
addr: Address = Address(int(elements[0]))
operands: str = elements[3]
target: Address | None = None
Copy link
Owner

@Kazhuu Kazhuu Dec 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More type annotations for this Python project would also be welcome in the future. Good start 👍

@@ -501,19 +579,26 @@ def parse_lines(lines, skip_calls, target_name): # noqa pylint: disable=unused-
continue

instruction_or_encoding = parse_line(line, num, current_function_name, current_format, target_info)
# print(instruction_or_encoding)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't leave commented out lines in the code. Probably mistake :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants