-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Fixed the SHEBANG detection #4290
Open
Webstonesl
wants to merge
11
commits into
antlr:master
Choose a base branch
from
Webstonesl:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
200df7e
Added Python3 target support for the Rust Grammar.
7138246
Changes applied as requested
b409ad5
Updated both the transform grammar and the RustParser
131e93b
Fixed the Cpp target of the rust grammar
af4ffb3
Fixed Shebang
Webstonesl 32ccadf
Merge remote-tracking branch 'original/master'
Webstonesl 9e6cf8d
Small mistake made, should fix the Cpp version
Webstonesl ed38dd0
Added a grammar transformer for CSharp
Webstonesl 02e7897
Made it target agnostic
Webstonesl 66fc0fb
Changed to have an integer version of next
Webstonesl f2fcdac
Let's see if this works.
Webstonesl 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 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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import sys, os, re, shutil | ||
from glob import glob | ||
from pathlib import Path | ||
|
||
def main(argv): | ||
for file in glob("*.g4"): | ||
fix(file) | ||
|
||
def fix(file_path): | ||
print("Altering " + file_path) | ||
if not os.path.exists(file_path): | ||
print(f"Could not find file: {file_path}") | ||
sys.exit(1) | ||
parts = os.path.split(file_path) | ||
file_name = parts[-1] | ||
|
||
shutil.move(file_path, file_path + ".bak") | ||
input_file = open(file_path + ".bak",'r') | ||
output_file = open(file_path, 'w') | ||
for x in input_file: | ||
if 'this._input' in x: | ||
x = x.replace("this._input", "this.InputStream") | ||
|
||
|
||
output_file.write(x) | ||
output_file.flush() | ||
|
||
print("Writing ...") | ||
input_file.close() | ||
output_file.close() | ||
|
||
if __name__ == '__main__': | ||
main(sys.argv) |
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.
Strictly speaking, this is not "target agnostic" (#4286 (comment)) because
!=
is a target-specific operator. The entire expression should go in a base class, which is already done for both lexer and parser. Please add a "is...()" method, reference that here, and implement the methods for each of the targets.