int syntax_check(const char *string)
{
        const char *src = string;
        int total = 0;
        int flag = 0;
        while (*src) {
                switch (*src) {
                        case '{':    //如果是正括号,只管将计数器递加,因为“可能”后面会将它递减的,未来是未决的
                                total++;
                                flag = 1;
                                break;
                        case '}':  
                                if (flag) 
                                        return -1;
                                total--;
                                break;
                        default:
                                flag = 0;
                                break;
                }
                if (total < 0) {   //只要计数器小于0了,就说明已经多了一个反括号,由于是向后这一个方面扫描的,所以不能指望再有正括号与之抵消了
                        break;
                }
                *src ++;
        }
        return total;
}