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
Additional refactors based on the PR #2206 #2379
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c6985a7
Refactor in comments
Anselmoo 94abb4a
Change not any to all
Anselmoo ce26ad6
Reconstruct for-if by any
Anselmoo ab0a55c
Remove double if-if constructions
Anselmoo 06fbd99
Remove double if-if constructions
Anselmoo 8f6b140
Simplified return
Anselmoo 46c09aa
Refactor if else construction
Anselmoo 926662e
Replace summation by enumerate
Anselmoo 30fbdb7
Reformat
Anselmoo File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
|
@@ -67,12 +67,10 @@ def parse_graminit_h(self, filename): | |
return False | ||
self.symbol2number = {} | ||
self.number2symbol = {} | ||
lineno = 0 | ||
for line in f: | ||
lineno += 1 | ||
for lineno, line in enumerate(f, start=1): | ||
mo = re.match(r"^#define\s+(\w+)\s+(\d+)$", line) | ||
if not mo and line.strip(): | ||
print("%s(%s): can't parse %s" % (filename, lineno, line.strip())) | ||
print("%s(%s): can't parse %s" % (filename, lineno+1, line.strip())) | ||
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. You need either this or the start=1 but not both. 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. Yes, you are right! |
||
else: | ||
symbol, number = mo.groups() | ||
number = int(number) | ||
|
@@ -200,16 +198,13 @@ def parse_graminit_c(self, filename): | |
mo = re.match(r"static label labels\[(\d+)\] = {$", line) | ||
assert mo, (lineno, line) | ||
nlabels = int(mo.group(1)) | ||
for i in range(nlabels): | ||
for _ in range(nlabels): | ||
lineno, line = lineno + 1, next(f) | ||
mo = re.match(r'\s+{(\d+), (0|"\w+")},$', line) | ||
assert mo, (lineno, line) | ||
x, y = mo.groups() | ||
x = int(x) | ||
if y == "0": | ||
y = None | ||
else: | ||
y = eval(y) | ||
y = None if y == "0" else eval(y) | ||
labels.append((x, y)) | ||
lineno, line = lineno + 1, next(f) | ||
assert line == "};\n", (lineno, line) | ||
|
This file contains 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
Oops, something went wrong.
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.
What does 28 mean here?
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.
Sorry, the number
28
is just a filler for the help-functions, but actually not needed