]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/Ecc/CodeFragmentCollector.py
BaseTools:Fix a ECC issue
[mirror_edk2.git] / BaseTools / Source / Python / Ecc / CodeFragmentCollector.py
1 ## @file
2 # preprocess source file
3 #
4 # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
5 #
6 # This program and the accompanying materials
7 # are licensed and made available under the terms and conditions of the BSD License
8 # which accompanies this distribution. The full text of the license may be found at
9 # http://opensource.org/licenses/bsd-license.php
10 #
11 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 #
14
15 ##
16 # Import Modules
17 #
18
19 from __future__ import print_function
20 from __future__ import absolute_import
21 import re
22 import Common.LongFilePathOs as os
23 import sys
24 if sys.version_info.major == 3:
25 import antlr4 as antlr
26 from Ecc.CParser4.CLexer import CLexer
27 from Ecc.CParser4.CParser import CParser
28 else:
29 import antlr3 as antlr
30 antlr.InputStream = antlr.StringStream
31 from Ecc.CParser3.CLexer import CLexer
32 from Ecc.CParser3.CParser import CParser
33
34
35 from Ecc import FileProfile
36 from Ecc.CodeFragment import Comment
37 from Ecc.CodeFragment import PP_Directive
38 from Ecc.ParserWarning import Warning
39
40
41 ##define T_CHAR_SPACE ' '
42 ##define T_CHAR_NULL '\0'
43 ##define T_CHAR_CR '\r'
44 ##define T_CHAR_TAB '\t'
45 ##define T_CHAR_LF '\n'
46 ##define T_CHAR_SLASH '/'
47 ##define T_CHAR_BACKSLASH '\\'
48 ##define T_CHAR_DOUBLE_QUOTE '\"'
49 ##define T_CHAR_SINGLE_QUOTE '\''
50 ##define T_CHAR_STAR '*'
51 ##define T_CHAR_HASH '#'
52
53 (T_CHAR_SPACE, T_CHAR_NULL, T_CHAR_CR, T_CHAR_TAB, T_CHAR_LF, T_CHAR_SLASH, \
54 T_CHAR_BACKSLASH, T_CHAR_DOUBLE_QUOTE, T_CHAR_SINGLE_QUOTE, T_CHAR_STAR, T_CHAR_HASH) = \
55 (' ', '\0', '\r', '\t', '\n', '/', '\\', '\"', '\'', '*', '#')
56
57 SEPERATOR_TUPLE = ('=', '|', ',', '{', '}')
58
59 (T_COMMENT_TWO_SLASH, T_COMMENT_SLASH_STAR) = (0, 1)
60
61 (T_PP_INCLUDE, T_PP_DEFINE, T_PP_OTHERS) = (0, 1, 2)
62
63 ## The collector for source code fragments.
64 #
65 # PreprocessFile method should be called prior to ParseFile
66 #
67 # GetNext*** procedures mean these procedures will get next token first, then make judgement.
68 # Get*** procedures mean these procedures will make judgement on current token only.
69 #
70 class CodeFragmentCollector:
71 ## The constructor
72 #
73 # @param self The object pointer
74 # @param FileName The file that to be parsed
75 #
76 def __init__(self, FileName):
77 self.Profile = FileProfile.FileProfile(FileName)
78 self.Profile.FileLinesList.append(T_CHAR_LF)
79 self.FileName = FileName
80 self.CurrentLineNumber = 1
81 self.CurrentOffsetWithinLine = 0
82
83 self.__Token = ""
84 self.__SkippedChars = ""
85
86 ## __EndOfFile() method
87 #
88 # Judge current buffer pos is at file end
89 #
90 # @param self The object pointer
91 # @retval True Current File buffer position is at file end
92 # @retval False Current File buffer position is NOT at file end
93 #
94 def __EndOfFile(self):
95 NumberOfLines = len(self.Profile.FileLinesList)
96 SizeOfLastLine = NumberOfLines
97 if NumberOfLines > 0:
98 SizeOfLastLine = len(self.Profile.FileLinesList[-1])
99
100 if self.CurrentLineNumber == NumberOfLines and self.CurrentOffsetWithinLine >= SizeOfLastLine - 1:
101 return True
102 elif self.CurrentLineNumber > NumberOfLines:
103 return True
104 else:
105 return False
106
107 ## __EndOfLine() method
108 #
109 # Judge current buffer pos is at line end
110 #
111 # @param self The object pointer
112 # @retval True Current File buffer position is at line end
113 # @retval False Current File buffer position is NOT at line end
114 #
115 def __EndOfLine(self):
116 SizeOfCurrentLine = len(self.Profile.FileLinesList[self.CurrentLineNumber - 1])
117 if self.CurrentOffsetWithinLine >= SizeOfCurrentLine - 1:
118 return True
119 else:
120 return False
121
122 ## Rewind() method
123 #
124 # Reset file data buffer to the initial state
125 #
126 # @param self The object pointer
127 #
128 def Rewind(self):
129 self.CurrentLineNumber = 1
130 self.CurrentOffsetWithinLine = 0
131
132 ## __UndoOneChar() method
133 #
134 # Go back one char in the file buffer
135 #
136 # @param self The object pointer
137 # @retval True Successfully go back one char
138 # @retval False Not able to go back one char as file beginning reached
139 #
140 def __UndoOneChar(self):
141
142 if self.CurrentLineNumber == 1 and self.CurrentOffsetWithinLine == 0:
143 return False
144 elif self.CurrentOffsetWithinLine == 0:
145 self.CurrentLineNumber -= 1
146 self.CurrentOffsetWithinLine = len(self.__CurrentLine()) - 1
147 else:
148 self.CurrentOffsetWithinLine -= 1
149 return True
150
151 ## __GetOneChar() method
152 #
153 # Move forward one char in the file buffer
154 #
155 # @param self The object pointer
156 #
157 def __GetOneChar(self):
158 if self.CurrentOffsetWithinLine == len(self.Profile.FileLinesList[self.CurrentLineNumber - 1]) - 1:
159 self.CurrentLineNumber += 1
160 self.CurrentOffsetWithinLine = 0
161 else:
162 self.CurrentOffsetWithinLine += 1
163
164 ## __CurrentChar() method
165 #
166 # Get the char pointed to by the file buffer pointer
167 #
168 # @param self The object pointer
169 # @retval Char Current char
170 #
171 def __CurrentChar(self):
172 CurrentChar = self.Profile.FileLinesList[self.CurrentLineNumber - 1][self.CurrentOffsetWithinLine]
173 # if CurrentChar > 255:
174 # raise Warning("Non-Ascii char found At Line %d, offset %d" % (self.CurrentLineNumber, self.CurrentOffsetWithinLine), self.FileName, self.CurrentLineNumber)
175 return CurrentChar
176
177 ## __NextChar() method
178 #
179 # Get the one char pass the char pointed to by the file buffer pointer
180 #
181 # @param self The object pointer
182 # @retval Char Next char
183 #
184 def __NextChar(self):
185 if self.CurrentOffsetWithinLine == len(self.Profile.FileLinesList[self.CurrentLineNumber - 1]) - 1:
186 return self.Profile.FileLinesList[self.CurrentLineNumber][0]
187 else:
188 return self.Profile.FileLinesList[self.CurrentLineNumber - 1][self.CurrentOffsetWithinLine + 1]
189
190 ## __SetCurrentCharValue() method
191 #
192 # Modify the value of current char
193 #
194 # @param self The object pointer
195 # @param Value The new value of current char
196 #
197 def __SetCurrentCharValue(self, Value):
198 self.Profile.FileLinesList[self.CurrentLineNumber - 1][self.CurrentOffsetWithinLine] = Value
199
200 ## __SetCharValue() method
201 #
202 # Modify the value of current char
203 #
204 # @param self The object pointer
205 # @param Value The new value of current char
206 #
207 def __SetCharValue(self, Line, Offset, Value):
208 self.Profile.FileLinesList[Line - 1][Offset] = Value
209
210 ## __CurrentLine() method
211 #
212 # Get the list that contains current line contents
213 #
214 # @param self The object pointer
215 # @retval List current line contents
216 #
217 def __CurrentLine(self):
218 return self.Profile.FileLinesList[self.CurrentLineNumber - 1]
219
220 ## __InsertComma() method
221 #
222 # Insert ',' to replace PP
223 #
224 # @param self The object pointer
225 # @retval List current line contents
226 #
227 def __InsertComma(self, Line):
228
229
230 if self.Profile.FileLinesList[Line - 1][0] != T_CHAR_HASH:
231 BeforeHashPart = str(self.Profile.FileLinesList[Line - 1]).split(T_CHAR_HASH)[0]
232 if BeforeHashPart.rstrip().endswith(T_CHAR_COMMA) or BeforeHashPart.rstrip().endswith(';'):
233 return
234
235 if Line - 2 >= 0 and str(self.Profile.FileLinesList[Line - 2]).rstrip().endswith(','):
236 return
237
238 if Line - 2 >= 0 and str(self.Profile.FileLinesList[Line - 2]).rstrip().endswith(';'):
239 return
240
241 if str(self.Profile.FileLinesList[Line]).lstrip().startswith(',') or str(self.Profile.FileLinesList[Line]).lstrip().startswith(';'):
242 return
243
244 self.Profile.FileLinesList[Line - 1].insert(self.CurrentOffsetWithinLine, ',')
245
246 ## PreprocessFile() method
247 #
248 # Preprocess file contents, replace comments with spaces.
249 # In the end, rewind the file buffer pointer to the beginning
250 # BUGBUG: No !include statement processing contained in this procedure
251 # !include statement should be expanded at the same FileLinesList[CurrentLineNumber - 1]
252 #
253 # @param self The object pointer
254 #
255 def PreprocessFile(self):
256
257 self.Rewind()
258 InComment = False
259 DoubleSlashComment = False
260 HashComment = False
261 PPExtend = False
262 CommentObj = None
263 PPDirectiveObj = None
264 # HashComment in quoted string " " is ignored.
265 InString = False
266 InCharLiteral = False
267
268 self.Profile.FileLinesList = [list(s) for s in self.Profile.FileLinesListFromFile]
269 while not self.__EndOfFile():
270
271 if not InComment and self.__CurrentChar() == T_CHAR_DOUBLE_QUOTE:
272 InString = not InString
273
274 if not InComment and self.__CurrentChar() == T_CHAR_SINGLE_QUOTE:
275 InCharLiteral = not InCharLiteral
276 # meet new line, then no longer in a comment for // and '#'
277 if self.__CurrentChar() == T_CHAR_LF:
278 if HashComment and PPDirectiveObj is not None:
279 if PPDirectiveObj.Content.rstrip(T_CHAR_CR).endswith(T_CHAR_BACKSLASH):
280 PPDirectiveObj.Content += T_CHAR_LF
281 PPExtend = True
282 else:
283 PPExtend = False
284
285 EndLinePos = (self.CurrentLineNumber, self.CurrentOffsetWithinLine)
286
287 if InComment and DoubleSlashComment:
288 InComment = False
289 DoubleSlashComment = False
290 CommentObj.Content += T_CHAR_LF
291 CommentObj.EndPos = EndLinePos
292 FileProfile.CommentList.append(CommentObj)
293 CommentObj = None
294 if InComment and HashComment and not PPExtend:
295 InComment = False
296 HashComment = False
297 PPDirectiveObj.Content += T_CHAR_LF
298 PPDirectiveObj.EndPos = EndLinePos
299 FileProfile.PPDirectiveList.append(PPDirectiveObj)
300 PPDirectiveObj = None
301
302 if InString or InCharLiteral:
303 CurrentLine = "".join(self.__CurrentLine())
304 if CurrentLine.rstrip(T_CHAR_LF).rstrip(T_CHAR_CR).endswith(T_CHAR_BACKSLASH):
305 SlashIndex = CurrentLine.rindex(T_CHAR_BACKSLASH)
306 self.__SetCharValue(self.CurrentLineNumber, SlashIndex, T_CHAR_SPACE)
307
308 if InComment and not DoubleSlashComment and not HashComment:
309 CommentObj.Content += T_CHAR_LF
310 self.CurrentLineNumber += 1
311 self.CurrentOffsetWithinLine = 0
312 # check for */ comment end
313 elif InComment and not DoubleSlashComment and not HashComment and self.__CurrentChar() == T_CHAR_STAR and self.__NextChar() == T_CHAR_SLASH:
314 CommentObj.Content += self.__CurrentChar()
315 # self.__SetCurrentCharValue(T_CHAR_SPACE)
316 self.__GetOneChar()
317 CommentObj.Content += self.__CurrentChar()
318 # self.__SetCurrentCharValue(T_CHAR_SPACE)
319 CommentObj.EndPos = (self.CurrentLineNumber, self.CurrentOffsetWithinLine)
320 FileProfile.CommentList.append(CommentObj)
321 CommentObj = None
322 self.__GetOneChar()
323 InComment = False
324 # set comments to spaces
325 elif InComment:
326 if HashComment:
327 # // follows hash PP directive
328 if self.__CurrentChar() == T_CHAR_SLASH and self.__NextChar() == T_CHAR_SLASH:
329 InComment = False
330 HashComment = False
331 PPDirectiveObj.EndPos = (self.CurrentLineNumber, self.CurrentOffsetWithinLine - 1)
332 FileProfile.PPDirectiveList.append(PPDirectiveObj)
333 PPDirectiveObj = None
334 continue
335 else:
336 PPDirectiveObj.Content += self.__CurrentChar()
337 if PPExtend:
338 self.__SetCurrentCharValue(T_CHAR_SPACE)
339 else:
340 CommentObj.Content += self.__CurrentChar()
341 # self.__SetCurrentCharValue(T_CHAR_SPACE)
342 self.__GetOneChar()
343 # check for // comment
344 elif self.__CurrentChar() == T_CHAR_SLASH and self.__NextChar() == T_CHAR_SLASH:
345 InComment = True
346 DoubleSlashComment = True
347 CommentObj = Comment('', (self.CurrentLineNumber, self.CurrentOffsetWithinLine), None, T_COMMENT_TWO_SLASH)
348 # check for '#' comment
349 elif self.__CurrentChar() == T_CHAR_HASH and not InString and not InCharLiteral:
350 InComment = True
351 HashComment = True
352 PPDirectiveObj = PP_Directive('', (self.CurrentLineNumber, self.CurrentOffsetWithinLine), None)
353 # check for /* comment start
354 elif self.__CurrentChar() == T_CHAR_SLASH and self.__NextChar() == T_CHAR_STAR:
355 CommentObj = Comment('', (self.CurrentLineNumber, self.CurrentOffsetWithinLine), None, T_COMMENT_SLASH_STAR)
356 CommentObj.Content += self.__CurrentChar()
357 # self.__SetCurrentCharValue( T_CHAR_SPACE)
358 self.__GetOneChar()
359 CommentObj.Content += self.__CurrentChar()
360 # self.__SetCurrentCharValue( T_CHAR_SPACE)
361 self.__GetOneChar()
362 InComment = True
363 else:
364 self.__GetOneChar()
365
366 EndLinePos = (self.CurrentLineNumber, self.CurrentOffsetWithinLine)
367
368 if InComment and DoubleSlashComment:
369 CommentObj.EndPos = EndLinePos
370 FileProfile.CommentList.append(CommentObj)
371 if InComment and HashComment and not PPExtend:
372 PPDirectiveObj.EndPos = EndLinePos
373 FileProfile.PPDirectiveList.append(PPDirectiveObj)
374
375 self.Rewind()
376
377 def PreprocessFileWithClear(self):
378
379 self.Rewind()
380 InComment = False
381 DoubleSlashComment = False
382 HashComment = False
383 PPExtend = False
384 CommentObj = None
385 PPDirectiveObj = None
386 # HashComment in quoted string " " is ignored.
387 InString = False
388 InCharLiteral = False
389
390 self.Profile.FileLinesList = [list(s) for s in self.Profile.FileLinesListFromFile]
391 while not self.__EndOfFile():
392
393 if not InComment and self.__CurrentChar() == T_CHAR_DOUBLE_QUOTE:
394 InString = not InString
395
396 if not InComment and self.__CurrentChar() == T_CHAR_SINGLE_QUOTE:
397 InCharLiteral = not InCharLiteral
398 # meet new line, then no longer in a comment for // and '#'
399 if self.__CurrentChar() == T_CHAR_LF:
400 if HashComment and PPDirectiveObj is not None:
401 if PPDirectiveObj.Content.rstrip(T_CHAR_CR).endswith(T_CHAR_BACKSLASH):
402 PPDirectiveObj.Content += T_CHAR_LF
403 PPExtend = True
404 else:
405 PPExtend = False
406
407 EndLinePos = (self.CurrentLineNumber, self.CurrentOffsetWithinLine)
408
409 if InComment and DoubleSlashComment:
410 InComment = False
411 DoubleSlashComment = False
412 CommentObj.Content += T_CHAR_LF
413 CommentObj.EndPos = EndLinePos
414 FileProfile.CommentList.append(CommentObj)
415 CommentObj = None
416 if InComment and HashComment and not PPExtend:
417 InComment = False
418 HashComment = False
419 PPDirectiveObj.Content += T_CHAR_LF
420 PPDirectiveObj.EndPos = EndLinePos
421 FileProfile.PPDirectiveList.append(PPDirectiveObj)
422 PPDirectiveObj = None
423
424 if InString or InCharLiteral:
425 CurrentLine = "".join(self.__CurrentLine())
426 if CurrentLine.rstrip(T_CHAR_LF).rstrip(T_CHAR_CR).endswith(T_CHAR_BACKSLASH):
427 SlashIndex = CurrentLine.rindex(T_CHAR_BACKSLASH)
428 self.__SetCharValue(self.CurrentLineNumber, SlashIndex, T_CHAR_SPACE)
429
430 if InComment and not DoubleSlashComment and not HashComment:
431 CommentObj.Content += T_CHAR_LF
432 self.CurrentLineNumber += 1
433 self.CurrentOffsetWithinLine = 0
434 # check for */ comment end
435 elif InComment and not DoubleSlashComment and not HashComment and self.__CurrentChar() == T_CHAR_STAR and self.__NextChar() == T_CHAR_SLASH:
436 CommentObj.Content += self.__CurrentChar()
437 self.__SetCurrentCharValue(T_CHAR_SPACE)
438 self.__GetOneChar()
439 CommentObj.Content += self.__CurrentChar()
440 self.__SetCurrentCharValue(T_CHAR_SPACE)
441 CommentObj.EndPos = (self.CurrentLineNumber, self.CurrentOffsetWithinLine)
442 FileProfile.CommentList.append(CommentObj)
443 CommentObj = None
444 self.__GetOneChar()
445 InComment = False
446 # set comments to spaces
447 elif InComment:
448 if HashComment:
449 # // follows hash PP directive
450 if self.__CurrentChar() == T_CHAR_SLASH and self.__NextChar() == T_CHAR_SLASH:
451 InComment = False
452 HashComment = False
453 PPDirectiveObj.EndPos = (self.CurrentLineNumber, self.CurrentOffsetWithinLine - 1)
454 FileProfile.PPDirectiveList.append(PPDirectiveObj)
455 PPDirectiveObj = None
456 continue
457 else:
458 PPDirectiveObj.Content += self.__CurrentChar()
459 # if PPExtend:
460 # self.__SetCurrentCharValue(T_CHAR_SPACE)
461 else:
462 CommentObj.Content += self.__CurrentChar()
463 self.__SetCurrentCharValue(T_CHAR_SPACE)
464 self.__GetOneChar()
465 # check for // comment
466 elif self.__CurrentChar() == T_CHAR_SLASH and self.__NextChar() == T_CHAR_SLASH:
467 InComment = True
468 DoubleSlashComment = True
469 CommentObj = Comment('', (self.CurrentLineNumber, self.CurrentOffsetWithinLine), None, T_COMMENT_TWO_SLASH)
470 # check for '#' comment
471 elif self.__CurrentChar() == T_CHAR_HASH and not InString and not InCharLiteral:
472 InComment = True
473 HashComment = True
474 PPDirectiveObj = PP_Directive('', (self.CurrentLineNumber, self.CurrentOffsetWithinLine), None)
475 # check for /* comment start
476 elif self.__CurrentChar() == T_CHAR_SLASH and self.__NextChar() == T_CHAR_STAR:
477 CommentObj = Comment('', (self.CurrentLineNumber, self.CurrentOffsetWithinLine), None, T_COMMENT_SLASH_STAR)
478 CommentObj.Content += self.__CurrentChar()
479 self.__SetCurrentCharValue( T_CHAR_SPACE)
480 self.__GetOneChar()
481 CommentObj.Content += self.__CurrentChar()
482 self.__SetCurrentCharValue( T_CHAR_SPACE)
483 self.__GetOneChar()
484 InComment = True
485 else:
486 self.__GetOneChar()
487
488 EndLinePos = (self.CurrentLineNumber, self.CurrentOffsetWithinLine)
489
490 if InComment and DoubleSlashComment:
491 CommentObj.EndPos = EndLinePos
492 FileProfile.CommentList.append(CommentObj)
493 if InComment and HashComment and not PPExtend:
494 PPDirectiveObj.EndPos = EndLinePos
495 FileProfile.PPDirectiveList.append(PPDirectiveObj)
496 self.Rewind()
497
498 ## ParseFile() method
499 #
500 # Parse the file profile buffer to extract fd, fv ... information
501 # Exception will be raised if syntax error found
502 #
503 # @param self The object pointer
504 #
505 def ParseFile(self):
506 self.PreprocessFile()
507 # restore from ListOfList to ListOfString
508 self.Profile.FileLinesList = ["".join(list) for list in self.Profile.FileLinesList]
509 FileStringContents = ''
510 for fileLine in self.Profile.FileLinesList:
511 FileStringContents += fileLine
512 cStream = antlr.InputStream(FileStringContents)
513 lexer = CLexer(cStream)
514 tStream = antlr.CommonTokenStream(lexer)
515 parser = CParser(tStream)
516 parser.translation_unit()
517
518 def ParseFileWithClearedPPDirective(self):
519 self.PreprocessFileWithClear()
520 # restore from ListOfList to ListOfString
521 self.Profile.FileLinesList = ["".join(list) for list in self.Profile.FileLinesList]
522 FileStringContents = ''
523 for fileLine in self.Profile.FileLinesList:
524 FileStringContents += fileLine
525 cStream = antlr.InputStream(FileStringContents)
526 lexer = CLexer(cStream)
527 tStream = antlr.CommonTokenStream(lexer)
528 parser = CParser(tStream)
529 parser.translation_unit()
530
531 def CleanFileProfileBuffer(self):
532 FileProfile.CommentList = []
533 FileProfile.PPDirectiveList = []
534 FileProfile.PredicateExpressionList = []
535 FileProfile.FunctionDefinitionList = []
536 FileProfile.VariableDeclarationList = []
537 FileProfile.EnumerationDefinitionList = []
538 FileProfile.StructUnionDefinitionList = []
539 FileProfile.TypedefDefinitionList = []
540 FileProfile.FunctionCallingList = []
541
542 def PrintFragments(self):
543
544 print('################# ' + self.FileName + '#####################')
545
546 print('/****************************************/')
547 print('/*************** COMMENTS ***************/')
548 print('/****************************************/')
549 for comment in FileProfile.CommentList:
550 print(str(comment.StartPos) + comment.Content)
551
552 print('/****************************************/')
553 print('/********* PREPROCESS DIRECTIVES ********/')
554 print('/****************************************/')
555 for pp in FileProfile.PPDirectiveList:
556 print(str(pp.StartPos) + pp.Content)
557
558 print('/****************************************/')
559 print('/********* VARIABLE DECLARATIONS ********/')
560 print('/****************************************/')
561 for var in FileProfile.VariableDeclarationList:
562 print(str(var.StartPos) + var.Modifier + ' '+ var.Declarator)
563
564 print('/****************************************/')
565 print('/********* FUNCTION DEFINITIONS *********/')
566 print('/****************************************/')
567 for func in FileProfile.FunctionDefinitionList:
568 print(str(func.StartPos) + func.Modifier + ' '+ func.Declarator + ' ' + str(func.NamePos))
569
570 print('/****************************************/')
571 print('/************ ENUMERATIONS **************/')
572 print('/****************************************/')
573 for enum in FileProfile.EnumerationDefinitionList:
574 print(str(enum.StartPos) + enum.Content)
575
576 print('/****************************************/')
577 print('/*********** STRUCTS/UNIONS *************/')
578 print('/****************************************/')
579 for su in FileProfile.StructUnionDefinitionList:
580 print(str(su.StartPos) + su.Content)
581
582 print('/****************************************/')
583 print('/********* PREDICATE EXPRESSIONS ********/')
584 print('/****************************************/')
585 for predexp in FileProfile.PredicateExpressionList:
586 print(str(predexp.StartPos) + predexp.Content)
587
588 print('/****************************************/')
589 print('/************** TYPEDEFS ****************/')
590 print('/****************************************/')
591 for typedef in FileProfile.TypedefDefinitionList:
592 print(str(typedef.StartPos) + typedef.ToType)
593
594 if __name__ == "__main__":
595
596 collector = CodeFragmentCollector(sys.argv[1])
597 collector.PreprocessFile()
598 print("For Test.")