-
Notifications
You must be signed in to change notification settings - Fork 2
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
pushing working parser #1
Open
diyorg07
wants to merge
8
commits into
thomas-robinson:master
Choose a base branch
from
diyorg07:diyorzakirov07/mkmf
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 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
992f028
pushing working parser
03fec73
typo fix
c7f25ef
commnets for parser
a7d34e7
adding parseTest and updating README
3879c97
updating README, adding --verbose and -v to parserTest
e4f7c8a
mostly working Makefile writer
421b55d
doxygen comments for parseShort
6ef53e9
verbose for writeMakefile
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,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>mkmf2</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.python.pydev.PyDevBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.python.pydev.pythonNature</nature> | ||
</natures> | ||
</projectDescription> |
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,5 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<?eclipse-pydev version="1.0"?><pydev_project> | ||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property> | ||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python interpreter</pydev_property> | ||
</pydev_project> |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#!/bin/python | ||
import re | ||
import re; | ||
|
||
verbose = True | ||
vv = False | ||
|
@@ -13,25 +13,57 @@ | |
print(fname, ":\n ",fcontens) | ||
f.close() | ||
|
||
|
||
""" Set up the regex to find use statements ^\s*use """ | ||
module_dependencies = [] | ||
findUse = re.compile('^\s*use', re.IGNORECASE) | ||
findOnly = re.compile('only\s*:', re.IGNORECASE) | ||
""" Parse each line of the file for the regex ^\s*use """ | ||
findUseAmp = re.compile('^\s*use&', re.IGNORECASE) | ||
findUseAmpSpc = re.compile('^\s*use\s+&', re.IGNORECASE) | ||
|
||
|
||
'''Parse each line of the file for the regex ^\s*use ''' | ||
if verbose or vv: | ||
print('Parse each line of the file for the regex ^\s*use ') | ||
for line in fcontents.splitlines(): | ||
if findUse.match(line): | ||
for index, line in enumerate(fcontents.splitlines()): | ||
if findUse.match(line): | ||
if verbose or vv: | ||
print(line) | ||
""" Split the line on a , because of multiple module possibility on a line """ | ||
splitModLineCom = line.split(",") | ||
splitModLineCom = line.split(",") | ||
print(splitModLineCom) | ||
for mods in splitModLineCom: | ||
""" If the current string has USE in it, split on white space. The second member of this list is a module """ | ||
if findUse.match(mods): | ||
if (findUseAmp.match(mods) or findUseAmpSpc.match(mods)): | ||
if fcontents.splitlines()[index+1].split(",")[1]: | ||
splitmodLineCom = fcontents.splitlines()[index+1] | ||
print(splitmodLineCom) | ||
for mods in splitModLineCom: | ||
alreadyExists = False | ||
for md in module_dependencies: | ||
if md == mods[0]: | ||
alreadyExists = True | ||
if vv: | ||
print(fname,": the module ",md," is listd more than once. only keeping one") | ||
break; | ||
if not alreadyExists: | ||
module_dependencies.append(mods[0]) | ||
else: | ||
temp = 2 | ||
while not fcontents.splitlines()[index+temp][1]: | ||
temp += 1 | ||
splitmodLineCom = fcontents.splitlines()[index+temp] | ||
for mods in splitModLineCom: | ||
alreadyExists = False | ||
for md in module_dependencies: | ||
if md == mods[0]: | ||
alreadyExists = True | ||
if vv: | ||
print(fname,": the module ",md," is listd more than once. only keeping one") | ||
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. @diyorzakirov07 another "listed" typo |
||
break; | ||
if not alreadyExists: | ||
module_dependencies.append(mods[0]) | ||
if findUse.match(mods) and len(splitModLineCom) > 1: | ||
mod1 = mods.split() | ||
alreadyExist = False | ||
""" Get rid of dupicate mentions of a module """ | ||
for md in module_dependencies: | ||
if md == mod1[1]: | ||
alreadyExist = True | ||
|
@@ -40,7 +72,11 @@ | |
break | ||
if not alreadyExist: | ||
module_dependencies.append(mod1[1]) | ||
|
||
|
||
|
||
|
||
|
||
|
||
if verbose or vv: | ||
print("The dependencies for ",fname," are ",module_dependencies) | ||
|
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,63 @@ | ||
#!/bin/python | ||
import re; | ||
import os; | ||
|
||
fName = "diag_manager.F90" | ||
|
||
|
||
##Parses Fortran file and returns module dependencies | ||
# | ||
#This function takes in a file to parse through. | ||
#Using regex pattern matching a module list is populated, cleaned up, and returned without duplicates. | ||
def getModules(fileName): | ||
MODS = [] | ||
|
||
fileContents = open(fileName).read() | ||
|
||
##Regex pattern to find matches in the file | ||
#Checks for USE and possible & on the same or next line, until module name is found signified by the '?' | ||
#Ignores cases and tries to match on all lines | ||
patternMatch = re.compile('^ *USE[ &\n]+.*?[ &\n]*,', re.IGNORECASE | re.M) | ||
|
||
##Finds all possible matches in the file | ||
#Puts all possible matches in a list | ||
matches = re.findall(patternMatch, fileContents) | ||
|
||
##Grooms and populates return list of modules | ||
#Removes spaces, characters from pattern matching, and checks for duplicates | ||
for match in matches: | ||
match = match.lower().strip() | ||
badChars = ["use", "&", '\n', ' ', ','] | ||
#clean up the matches | ||
for char in badChars: | ||
match = match.replace(char, '') | ||
if not match in MODS: | ||
MODS.append(match) | ||
|
||
|
||
return MODS | ||
|
||
##Creates a Makefile.am | ||
#Creates a Makefile.am in the path provided, resolving all the dependencies | ||
def writeModules(modules, path): | ||
|
||
makefile = open('Makefile.am', 'w') | ||
|
||
fileList = os.listdir(path) | ||
|
||
fortranMatch = re.compile('[.F90&]') | ||
|
||
makefile.write("noinst_LTLIBRARIES = " + path + ".la\n") | ||
|
||
for file in fileList: | ||
if fotranMatch.match(file): | ||
makefile.write(file + "\\n") | ||
|
||
for mod in modules: | ||
makefile.write(mod + ".$(FC_MODEXT) : " + mod + ".$(OBJEXT)\n") | ||
|
||
|
||
if __name__ == '__main__': | ||
#testing diag_manager.F90 | ||
print(getModules(fName)) | ||
|
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.
There is a typo in "listed"