public function __construct($scanner, $_symTable, $array) { $arrayType = $array->variable->symType; if (!is_a($arrayType, 'vendor\\SemanticParser\\Nodes\\SymArrayType')) { SemanticException::varAccessTypeMismatch($scanner, $arrayType, 'array'); } $this->array = $array; $this->indexes = []; $continue = true; $idx = 0; while (!$scanner->get()->isOperator(']')) { if (!$continue) { parent::simpleException($scanner, ["<OPERATOR ']'>"]); } $this->indexes[$idx] = new Expression($scanner, $_symTable); if (!$arrayType->checkIndex($this->indexes[$idx], $idx, $_symTable)) { SemanticException::raw($scanner, "Array index type mismatch"); } $idx++; $continue = $scanner->get()->isOperator(','); if ($scanner->get()->isOperator(']')) { break; } $scanner->next(); } if ($idx != count($arrayType->dimensions)) { SemanticException::raw($scanner, "Array should be dereferenced completely"); } $this->symType = $arrayType->type; if ($continue) { parent::simpleException($scanner, ['<INDEX-EXPRESSION>']); } $scanner->next(); }
public function __construct($scanner, $_symTable, $record) { $recType = $record->variable->symType; if (is_a($recType, 'vendor\\SemanticParser\\Nodes\\SymAliasType')) { $recType = $recType->getBase(); } if (!is_a($recType, 'vendor\\SemanticParser\\Nodes\\SymRecordType')) { SemanticException::varAccessTypeMismatch($scanner, $recType, 'record'); } if (!$scanner->get()->isIdentifier()) { parent::simpleException($scanner, ['<FIELD-DESIGNATOR>']); } $identifier = $scanner->get()->getValue(); $designatorType = $recType->getFieldType($identifier); if ($designatorType == null) { SemanticException::undeclared($scanner, $identifier->getValue()); } $this->symType = $designatorType; $this->record = $record; $this->designator = $scanner->get(); $scanner->next(); }