| 239 | # Get*** procedures mean these procedures will make judgement on current token only. |
| 240 | # |
| 241 | class FdfParser: |
| 242 | ## The constructor |
| 243 | # |
| 244 | # @param self The object pointer |
| 245 | # @param FileName The file that to be parsed |
| 246 | # |
| 247 | def __init__(self, FileName): |
| 248 | self.Profile = FileProfile(FileName) |
| 249 | self.FileName = FileName |
| 250 | self.CurrentLineNumber = 1 |
| 251 | self.CurrentOffsetWithinLine = 0 |
| 252 | self.CurrentFdName = None |
| 253 | self.CurrentFvName = None |
| 254 | self._Token = "" |
| 255 | self._SkippedChars = "" |
| 256 | GlobalData.gFdfParser = self |
| 257 | |
| 258 | # Used to section info |
| 259 | self._CurSection = [] |
| 260 | # Key: [section name, UI name, arch] |
| 261 | # Value: {MACRO_NAME: MACRO_VALUE} |
| 262 | self._MacroDict = tdict(True, 3) |
| 263 | self._PcdDict = OrderedDict() |
| 264 | |
| 265 | self._WipeOffArea = [] |
| 266 | if GenFdsGlobalVariable.WorkSpaceDir == '': |
| 267 | GenFdsGlobalVariable.WorkSpaceDir = os.getenv("WORKSPACE") |
| 268 | |
| 269 | ## _SkipWhiteSpace() method |
| 270 | # |
| 271 | # Skip white spaces from current char. |
| 272 | # |
| 273 | # @param self The object pointer |
| 274 | # |
| 275 | def _SkipWhiteSpace(self): |
| 276 | while not self._EndOfFile(): |
| 277 | if self._CurrentChar() in {TAB_PRINTCHAR_NUL, T_CHAR_CR, TAB_LINE_BREAK, TAB_SPACE_SPLIT, T_CHAR_TAB}: |
| 278 | self._SkippedChars += str(self._CurrentChar()) |
| 279 | self._GetOneChar() |
| 280 | else: |
| 281 | return |
| 282 | return |
| 283 | |
| 284 | ## _EndOfFile() method |
| 285 | # |
| 286 | # Judge current buffer pos is at file end |
| 287 | # |
| 288 | # @param self The object pointer |
| 289 | # @retval True Current File buffer position is at file end |
| 290 | # @retval False Current File buffer position is NOT at file end |
| 291 | # |
| 292 | def _EndOfFile(self): |
| 293 | NumberOfLines = len(self.Profile.FileLinesList) |
| 294 | SizeOfLastLine = len(self.Profile.FileLinesList[-1]) |
| 295 | if self.CurrentLineNumber == NumberOfLines and self.CurrentOffsetWithinLine >= SizeOfLastLine - 1: |
| 296 | return True |
| 297 | if self.CurrentLineNumber > NumberOfLines: |
| 298 | return True |
no outgoing calls
no test coverage detected