Added a list iterator for lineanalyzer in parseheader.
This commit is contained in:
Binary file not shown.
+12
-3
@@ -8,14 +8,23 @@ class ANALYZEOBJECT:
|
|||||||
_passes = count(0)
|
_passes = count(0)
|
||||||
_analyzed = []
|
_analyzed = []
|
||||||
|
|
||||||
def __exit__(self, *exc):
|
|
||||||
return False
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.passes = 0
|
self.passes = 0
|
||||||
self.analyzeline = []
|
self.analyzeline = []
|
||||||
self.analyzed = []
|
self.analyzed = []
|
||||||
|
self.comment = False
|
||||||
|
|
||||||
|
def analyze(self,l):
|
||||||
|
if l.startswith('/*') or l.startswith('/**'):
|
||||||
|
self.comment = True
|
||||||
|
if l.endswith('*/') or l.endswith('**/'):
|
||||||
|
self.comment = False
|
||||||
|
return l
|
||||||
|
if self.comment == True:
|
||||||
|
if l.startswith('*') or l.startswith('**'):
|
||||||
|
return l
|
||||||
|
if l.startswith(' *'):
|
||||||
|
return l
|
||||||
|
|
||||||
class ANALYZER(ANALYZEOBJECT):
|
class ANALYZER(ANALYZEOBJECT):
|
||||||
_ids = count(0)
|
_ids = count(0)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ Contains class PARSER
|
|||||||
from itertools import count
|
from itertools import count
|
||||||
import os
|
import os
|
||||||
from tokenizer import TOKENIZER
|
from tokenizer import TOKENIZER
|
||||||
|
from lineanalyzer import ANALYZER
|
||||||
|
|
||||||
#Element type definitions. Used in the parse process.
|
#Element type definitions. Used in the parse process.
|
||||||
ELEMENT_TYPE_PREPROCESS = 1
|
ELEMENT_TYPE_PREPROCESS = 1
|
||||||
@@ -81,7 +82,8 @@ substitute = False
|
|||||||
|
|
||||||
class PARSEOBJECT:
|
class PARSEOBJECT:
|
||||||
_passes = count(0)
|
_passes = count(0)
|
||||||
|
_lineanalyzer = ANALYZER()
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.tokenize = TOKENIZER()
|
self.tokenize = TOKENIZER()
|
||||||
self.parseline = []
|
self.parseline = []
|
||||||
@@ -107,11 +109,20 @@ class PARSEOBJECT:
|
|||||||
def parseheader(self, fl, fn):
|
def parseheader(self, fl, fn):
|
||||||
tempfile = []
|
tempfile = []
|
||||||
tempfile1 = []
|
tempfile1 = []
|
||||||
|
templine = []
|
||||||
outfile = ''
|
outfile = ''
|
||||||
|
rr = 'next'
|
||||||
|
count = 0
|
||||||
self.parse_reset()
|
self.parse_reset()
|
||||||
for l in fl:
|
i = iter(fl)
|
||||||
analyzed_line = self.analyzer(l)
|
while i:
|
||||||
tempfile.append(analyzed_line)
|
rr = self._lineanalyzer.analyze(next(i))
|
||||||
|
if rr == 'next':
|
||||||
|
count += 1
|
||||||
|
else:
|
||||||
|
templine.append(rr)
|
||||||
|
tempfile.append(templine)
|
||||||
|
count += 1
|
||||||
self.inc_passes()
|
self.inc_passes()
|
||||||
for l in tempfile:
|
for l in tempfile:
|
||||||
analyzed_line = self.token_analyzer(l)
|
analyzed_line = self.token_analyzer(l)
|
||||||
|
|||||||
Reference in New Issue
Block a user