self.asplit_pat = "^\(<type>.*[^a-zA-Z0-9_]\)\(<name>[a-zA-Z0-9_]+\)$"
self.comment1_pat = "\(<rest>.*\)//.*"
# note that the next pattern only removes comments that are wholly within one line
- self.comment2_pat = "\(<rest>.*\)/\*.*\*/"
+ self.comment2_pat = "\(<rest1>.*\)/\*.*\*/\(<rest2>.*\)"
def compilepatterns(self):
for name in dir(self):
return file
def setinput(self, scan = sys.stdin):
+ if not type(scan) in (TupleType, ListType):
+ scan = [scan]
+ self.allscaninputs = scan
+ self._nextinput()
+
+ def _nextinput(self):
+ if not self.allscaninputs:
+ return 0
+ scan = self.allscaninputs[0]
+ self.allscaninputs = self.allscaninputs[1:]
self.closescan()
if scan:
if type(scan) == StringType:
self.scanfile = file
self.scanmine = mine
self.lineno = 0
+ return 1
def openinput(self, filename):
if not os.path.isabs(filename):
raise Error, "input file not set"
self.line = self.scanfile.readline()
if not self.line:
+ if self._nextinput():
+ return self.getline()
raise EOFError
self.lineno = self.lineno + 1
return self.line
except EOFError: break
if self.comment1.match(line) >= 0:
line = self.comment1.group('rest')
- if self.comment2.match(line) >= 0:
- line = self.comment2.group('rest')
+ while self.comment2.match(line) >= 0:
+ line = self.comment2.group('rest1')+self.comment2.group('rest2')
if self.defsfile and self.sym.match(line) >= 0:
self.dosymdef()
continue
raw = self.line
while self.tail.search(raw) < 0:
line = self.getline()
+ if self.comment1.match(line) >= 0:
+ line = self.comment1.group('rest')
+ while self.comment2.match(line) >= 0:
+ line = self.comment2.group('rest1')+self.comment2.group('rest2')
raw = raw + line
self.processrawspec(raw)