MCPcopy Create free account
hub / github.com/numpy/numpy / crackline

Function crackline

numpy/f2py/crackfortran.py:700–856  ·  view source on GitHub ↗

reset=-1 --- initialize reset=0 --- crack the line reset=1 --- final check if mismatch of blocks occurred Cracked data is saved in grouplist[0].

(line, reset=0)

Source from the content-addressed store, hash-verified

698crackline_bindlang = re.compile(r'\s*bind\(\s*(?P<lang>[^,]+)\s*,\s*name\s*=\s*"(?P<lang_name>[^"]+)"\s*\)', re.I)
699
700def crackline(line, reset=0):
701 """
702 reset=-1 --- initialize
703 reset=0 --- crack the line
704 reset=1 --- final check if mismatch of blocks occurred
705
706 Cracked data is saved in grouplist[0].
707 """
708 global beginpattern, groupcounter, groupname, groupcache, grouplist
709 global filepositiontext, currentfilename, neededmodule, expectbegin
710 global skipblocksuntil, skipemptyends, previous_context, gotnextfile
711
712 _, has_semicolon = split_by_unquoted(line, ";")
713 if has_semicolon and not (f2pyenhancementspattern[0].match(line) or
714 multilinepattern[0].match(line)):
715 # XXX: non-zero reset values need testing
716 assert reset == 0, repr(reset)
717 # split line on unquoted semicolons
718 line, semicolon_line = split_by_unquoted(line, ";")
719 while semicolon_line:
720 crackline(line, reset)
721 line, semicolon_line = split_by_unquoted(semicolon_line[1:], ";")
722 crackline(line, reset)
723 return
724 if reset < 0:
725 groupcounter = 0
726 groupname = {groupcounter: ''}
727 groupcache = {groupcounter: {}}
728 grouplist = {groupcounter: []}
729 groupcache[groupcounter]['body'] = []
730 groupcache[groupcounter]['vars'] = {}
731 groupcache[groupcounter]['block'] = ''
732 groupcache[groupcounter]['name'] = ''
733 neededmodule = -1
734 skipblocksuntil = -1
735 return
736 if reset > 0:
737 fl = 0
738 if f77modulename and neededmodule == groupcounter:
739 fl = 2
740 while groupcounter > fl:
741 outmess('crackline: groupcounter=%s groupname=%s\n' %
742 (repr(groupcounter), repr(groupname)))
743 outmess(
744 'crackline: Mismatch of blocks encountered. Trying to fix it by assuming "end" statement.\n')
745 grouplist[groupcounter - 1].append(groupcache[groupcounter])
746 grouplist[groupcounter - 1][-1]['body'] = grouplist[groupcounter]
747 del grouplist[groupcounter]
748 groupcounter = groupcounter - 1
749 if f77modulename and neededmodule == groupcounter:
750 grouplist[groupcounter - 1].append(groupcache[groupcounter])
751 grouplist[groupcounter - 1][-1]['body'] = grouplist[groupcounter]
752 del grouplist[groupcounter]
753 groupcounter = groupcounter - 1 # end interface
754 grouplist[groupcounter - 1].append(groupcache[groupcounter])
755 grouplist[groupcounter - 1][-1]['body'] = grouplist[groupcounter]
756 del grouplist[groupcounter]
757 groupcounter = groupcounter - 1 # end module

Callers

nothing calls this directly

Calls 7

split_by_unquotedFunction · 0.85
markouterparenFunction · 0.85
_simplifyargsFunction · 0.85
analyzelineFunction · 0.85
endswithMethod · 0.80
lowerMethod · 0.80
outmessFunction · 0.70

Tested by

no test coverage detected