Parses DIM statement and creates a symbol table entry for an array of the specified dimensions.
(self)
| 516 | self.__symbol_table[left] = right |
| 517 | |
| 518 | def __dimstmt(self): |
| 519 | """Parses DIM statement and creates a symbol |
| 520 | table entry for an array of the specified |
| 521 | dimensions. |
| 522 | |
| 523 | """ |
| 524 | self.__advance() # Advance past DIM keyword |
| 525 | |
| 526 | # Extract the array name, append a suffix so |
| 527 | # that we can distinguish from simple variables |
| 528 | # in the symbol table |
| 529 | name = self.__token.lexeme + '_array' |
| 530 | self.__advance() # Advance past array name |
| 531 | |
| 532 | self.__consume(Token.LEFTPAREN) |
| 533 | |
| 534 | # Extract the dimensions |
| 535 | dimensions = [] |
| 536 | if not self.__tokenindex >= len(self.__tokenlist): |
| 537 | self.__expr() |
| 538 | dimensions.append(self.__operand_stack.pop()) |
| 539 | |
| 540 | while self.__token.category == Token.COMMA: |
| 541 | self.__advance() # Advance past comma |
| 542 | self.__expr() |
| 543 | dimensions.append(self.__operand_stack.pop()) |
| 544 | |
| 545 | self.__consume(Token.RIGHTPAREN) |
| 546 | |
| 547 | if len(dimensions) > 3: |
| 548 | raise SyntaxError("Maximum number of array dimensions is three " + |
| 549 | "in line " + str(self.__line_number)) |
| 550 | |
| 551 | self.__symbol_table[name] = BASICArray(dimensions) |
| 552 | |
| 553 | def __arrayassignmentstmt(self, name): |
| 554 | """Parses an assignment to an array variable |
no test coverage detected