Language: C++

#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
#define INF (1<<29)

int not[3]={2,1,0};
int and[3][3]={{0,0,0},{0,1,1},{0,1,2}};
int or[3][3]={{0,1,2},{1,1,2},{2,2,2}};
int p,q,r;
char s[128],*pos;
int formula(){
	char c=*pos++;
	switch(c){
	case '0':return 0;
	case '1':return 1;
	case '2':return 2;
	case 'P':return p;
	case 'Q':return q;
	case 'R':return r;
	case '-':return not[formula()];
	case '(':
		int a,b;
		a=formula();
		c=*pos++;
		b=formula();
		pos++;
		if(c=='*')return and[a][b];
		return or[a][b];
	}
	return -1;
}
int main(){
	while(cin>>s,s[0]!='.'){
		int ans=0;
		for(p=0;p<=2;p++){
			for(q=0;q<=2;q++){
				for(r=0;r<=2;r++){
					pos=s;
					if(formula()==2)ans++;
				}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Compiler output:
a.cc:9:5: error: expected unqualified-id before 'not' token
    9 | int not[3]={2,1,0};
      |     ^~~
a.cc:10:9: error: expected identifier before numeric constant
   10 | int and[3][3]={{0,0,0},{0,1,1},{0,1,2}};
      |         ^
a.cc:10:9: error: expected ']' before numeric constant
   10 | int and[3][3]={{0,0,0},{0,1,1},{0,1,2}};
      |         ^
      |         ]
a.cc:10:8: error: structured binding declaration cannot have type 'int'
   10 | int and[3][3]={{0,0,0},{0,1,1},{0,1,2}};
      |        ^
a.cc:10:8: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:10:8: error: empty structured binding declaration
a.cc:10:11: error: expected initializer before '[' token
   10 | int and[3][3]={{0,0,0},{0,1,1},{0,1,2}};
      |           ^
a.cc:11:5: error: expected unqualified-id before 'or' token
   11 | int or[3][3]={{0,1,2},{1,1,2},{2,2,2}};
      |     ^~
a.cc: In function 'int formula()':
a.cc:23:37: error: empty initializer for lambda init-capture
   23 |         case '-':return not[formula()];
      |                                     ^
a.cc: In lambda function:
a.cc:23:39: error: expected '{' before ';' token
   23 |         case '-':return not[formula()];
      |                                       ^
a.cc: In function 'int formula()':
a.cc:30:37: error: expected identifier before '[' token
   30 |                 if(c=='*')return and[a][b];
      |                                     ^
a.cc:30:37: error: expected ';' before '[' token
   30 |                 if(c=='*')return and[a][b];
      |                                     ^
      |                                     ;
a.cc: In lambda function:
a.cc:30:40: error: expected '{' before '[' token
   30 |                 if(c=='*')return and[a][b];
      |                                        ^
a.cc: In function 'int formula()':
a.cc:30:40: error: no match for 'operator[]' (operand types are 'formula()::<lambda()>' and 'int')
a.cc:31:24: error: expected primary-expression before 'or' token
   31 |                 return or[a][b];
      |                        ^~
a.cc: In lambda function:
a.cc:31:29: error: expected '{' before '[' token
   31 |                 return or[a][b];
      |                             ^
a.cc: In function 'int formula()':
a.cc:31:29: error: no match for 'operator[]' (operand types are 'formula()::<lambda()>' and 'int')