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