Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<cstring>
#include<map>
using namespace std;

vector<string> L;
int size[52];
map<pair<int, int>, int> V;
map<pair<int, int>, bool> A; 

int idx(char ch){
    if ( ch <= 'z' ) return ch - 'a';
    else return ch - 'A' + 26;
}

int getInt(string str, int &p ){
    string num = "";
    while( isdigit(str[p]) ) num += str[p++];
    if ( num.size() ) return atoi(num.c_str());
    int n = idx(str[p]);
    p += 2;
    int v = getInt(str, p);
    if ( v == -1 || size[n] <= v || !A[make_pair(n, v)] ) return -1;
    return V[make_pair(n, v)];
}

int compute(){
    for ( int i = 0; i < 52; i++ ) size[i] = 0;
    V = map<pair<int, int>, int>();
    A = map<pair<int, int>, bool>();
    for ( int i = 0; i < L.size() ;i++ ) {
	string line = L[i];
	if ( line.find('=') != string::npos ) {
	    int e = 0; while( line[e] != '=' ) e++;
	    e++;
	    int r = getInt(line, e);
	    int pos = 2;
	    int li = getInt(line, pos);
	    if ( li == -1 || r == -1 || li >= size[idx(line[0])]) return i+1;
	    V[make_pair(idx(line[0]), li)] = r;
	    A[make_pair(idx(line[0]), li)] = true;
	} else {
	    int pos = 2;
	    size[idx(line[0])] = getInt(line, pos);
	}
    }
    return 0;
}

main(){
    string str;
    while( cin >> str ){
	if ( str == "." ) break;
	L.clear(); L.push_back(str);
	while( cin >> str ){
	    if ( str == "." ) break;
	    L.push_back(str);
	}
	cout << compute() << endl;
    }
}

Compiler output:
a.cc: In function 'int getInt(std::string, int&)':
a.cc:25:21: error: reference to 'size' is ambiguous
   25 |     if ( v == -1 || size[n] <= v || !A[make_pair(n, v)] ) return -1;
      |                     ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:9:5: note:                 'int size [52]'
    9 | int size[52];
      |     ^~~~
a.cc: In function 'int compute()':
a.cc:30:36: error: reference to 'size' is ambiguous
   30 |     for ( int i = 0; i < 52; i++ ) size[i] = 0;
      |                                    ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:9:5: note:                 'int size [52]'
    9 | int size[52];
      |     ^~~~
a.cc:41:47: error: reference to 'size' is ambiguous
   41 |             if ( li == -1 || r == -1 || li >= size[idx(line[0])]) return i+1;
      |                                               ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:9:5: note:                 'int size [52]'
    9 | int size[52];
      |     ^~~~
a.cc:46:13: error: reference to 'size' is ambiguous
   46 |             size[idx(line[0])] = getInt(line, pos);
      |             ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:9:5: note:                 'int size [52]'
    9 | int size[52];
      |     ^~~~
a.cc: At global scope:
a.cc:52:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   52 | main(){
      | ^~~~