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
xdsl: parse dictionary as non-optional #342
Conversation
@@ -356,9 +356,11 @@ def parse_optional_char(self, | |||
|
|||
def parse_char(self, char: str, skip_white_space: bool = True) -> bool: | |||
assert (len(char) == 1) | |||
current_char = self.get_char() |
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.
helped me with debugging, might help someone else in the future
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.
Could you add a small docstring/comment on this?
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.
My personal opinion is that the code is fairly self-explanatory, I'm not sure what the dosctring would say. Happy to include one if you have a suggestion!
@@ -139,7 +139,7 @@ def get_char(self, | |||
self.skip_white_space() | |||
if self._pos is None: | |||
return None | |||
if self._pos.idx + n >= len(self.str): | |||
if self._pos.idx + n > len(self.str): |
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.
got an error when parsing the last character of the test inputs
I'll review this once the other one is merged or this PR is rebased, but otherwise this is exactly what we need yes! |
data = parser.parse_dictionary(parser.parse_optional_str_literal, | ||
parser.parse_optional_attribute) | ||
parser.parse_char("}") | ||
data = parser.parse_dictionary(parser.parse_str_literal, |
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.
good
@@ -356,9 +356,11 @@ def parse_optional_char(self, | |||
|
|||
def parse_char(self, char: str, skip_white_space: bool = True) -> bool: | |||
assert (len(char) == 1) | |||
current_char = self.get_char() |
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.
Could you add a small docstring/comment on this?
43bee61
to
ebf8b0d
Compare
Codecov ReportBase: 88.44% // Head: 88.73% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #342 +/- ##
==========================================
+ Coverage 88.44% 88.73% +0.28%
==========================================
Files 64 64
Lines 7815 7864 +49
Branches 1281 1286 +5
==========================================
+ Hits 6912 6978 +66
+ Misses 645 631 -14
+ Partials 258 255 -3
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
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.
LGTM!
Parse the whole dictionary, including opening and closing braces. This makes a number of things easier to implement, and lets us pass non-optional parsing functions for key and value