CAstDesignator* CParser::qualident(CAstScope *s) { // // qualident ::= ident { "[" expression "]" } // CToken t; // qualident -> ident ... CAstDesignator *id = ident(s); t = _scanner->Peek(); if (t.GetType() != tLBrak) return id; const CToken saveToken = id->GetToken(); const CSymbol* saveSymbol = id->GetSymbol(); CAstArrayDesignator *arrayId = new CAstArrayDesignator(saveToken, saveSymbol); if (!arrayId->GetType() || !arrayId->GetType()->IsArray()) { SetError(t, "access with index which is actually not an array"); return id; } free(id); while (t.GetType() == tLBrak) { // qualident -> ... "[" ... Consume(tLBrak); // qualident -> ... expression ... arrayId->AddIndex(expression(s)); // qualident -> ... "]" ... Consume(tRBrak); t = _scanner->Peek(); } arrayId->IndicesComplete(); return arrayId; }