Parsing of a command the netlist to the active circuit object. The name of the active circuit object is the last name in the global CIRCUITNAMES: CIRCUITNAMES[-1]. The circuit object itself is stored in the dictionary CIRCUITS under this name: circuitDict[CIRCUITNAMES[-1]]. :pa
(line, name, cirType)
| 526 | _addElement(newElement, name, cirType) |
| 527 | |
| 528 | def _parseCommand(line, name, cirType): |
| 529 | """ |
| 530 | Parsing of a command the netlist to the active circuit object. |
| 531 | The name of the active circuit object is the last name in the global |
| 532 | CIRCUITNAMES: CIRCUITNAMES[-1]. The circuit object itself is stored in the |
| 533 | dictionary CIRCUITS under this name: circuitDict[CIRCUITNAMES[-1]]. |
| 534 | |
| 535 | :param circuitDict: Dictionary to which the definition will be written, |
| 536 | defaults to CIRCUITS. |
| 537 | :type circuitDict: dictionary |
| 538 | |
| 539 | :param line: list with tokens from a netlist line |
| 540 | :type line: list with tokens |
| 541 | |
| 542 | :return: Errors: number of errors found in this line. |
| 543 | |
| 544 | :rtype: Integer |
| 545 | """ |
| 546 | global _CIRCUITNAMES |
| 547 | parDef = {} |
| 548 | model = None |
| 549 | errors = 0 |
| 550 | cmd = line[0].value.upper() |
| 551 | if cmd == 'LIB' or (len(cmd) >= 3 and cmd[:3] == 'INC'): |
| 552 | _parseLibrary(line, name, cirType) |
| 553 | elif cmd == 'PARAM': |
| 554 | for i in range(1, len(line)): |
| 555 | if line[i].type == 'PARDEF': |
| 556 | parName, parValue = line[i].value |
| 557 | parDef[parName] = parValue |
| 558 | else: |
| 559 | errors += 1 |
| 560 | _printError("Error: Expected a parameter definition.", line[i]) |
| 561 | if errors == 0: |
| 562 | _addParDef(name, cirType, parDef) |
| 563 | elif cmd == 'MODEL': |
| 564 | if len(line) < 3: |
| 565 | _printError("Error: Incomplete model specification.", line[-1]) |
| 566 | else: |
| 567 | newModelDef = modelDef() |
| 568 | if line[1].type == 'ID': |
| 569 | newModelDef.name = line[1].value |
| 570 | else: |
| 571 | errors += 1 |
| 572 | _printError("Error: Expected a model name.", line[1]) |
| 573 | if line[1].type == 'ID': |
| 574 | modelType = line[2].value |
| 575 | if modelType not in _MODELS.keys(): |
| 576 | errors += 1 |
| 577 | _printError("Error: Unknown model.", line[2]) |
| 578 | newModelDef.type = False |
| 579 | else: |
| 580 | newModelDef.type = line[2].value |
| 581 | else: |
| 582 | errors +=1 |
| 583 | _printError("Error: Expected a model type.", line[1]) |
| 584 | if len(line) > 3: |
| 585 | validParams = _MODELS[newModelDef.type].params |
no test coverage detected