// File: /workspace/github_cpp_makefile_star2_O1/zhengwangsun[P]pas2c/grammar.cpp
// Function: Analyze()
bool Analyze(void)                     //语法分析函数,返回分析结果
{
	int ip=1,X,a;
	int i,j,k,m,flag=1;
	AnalysisStack.push($);             //将$压栈 
	AnalysisStack.push(0);             //将文法开始符号Program压栈

	initTree(); 
	do{
		X=AnalysisStack.top();
		a=token[ip].type;
		
		if(X>=100||X==$)               //X是终结符或 $ 
		{
			if(X==a)                   //106: ε
			{
				AnalysisStack.pop();
				ip++;
			}
			else if(X==106)
				AnalysisStack.pop();
			else 
				return false;
		}
		else                           //X是非终结符
		{
			if(AnalysisTable[X][a-100]!=-1)
			{
				k=AnalysisTable[X][a-100];		
				AnalysisStack.pop();
				for(m=0;g[k].right[m+1]!=-1;m++)
					;
				for(int n=m;n>=0;n--)
					AnalysisStack.push(g[k].right[n]);
			
				// M[X,a]=X->Y1Y2.....Yk
				//构造树节点操作
			    int temp=DFS(0);//X节点的下标 
			    if(tree.node[temp].type==g[k].left) //搜索正确
			    {
			    	for(int i=0;g[k].right[i]!=-1;i++)
			    	{
			    		//1.对X节点：需要进行儿子节点的处理；
					    tree.node[temp].child[tree.node[temp].childNum++]=tree.size+1;
					    
					    //2.对Y1Y2......Yk需要新建节点
						tree.node[tree.size+1].type=g[k].right[i];
						if(g[k].right[i]>=100)
						{
							tree.node[tree.size+1].isT=true;
							if(g[k].right[i]!=106)
							{
							//	tree.node[tree.size+1].row=token[tokenCount].line;
							//	tree.node[tree.size+1].numType=tokenCount;  //测试 
							//    tokenCount++;
							}	
						}	 
						 	
						tree.node[tree.size+1].code=getVnVtString(g[k].right[i]);
				       // tree.node[tree.szie+1].value= 
				        //id单独处理 （把值和行数填入） 
						if(g[k].right[i]==101)
						{
							tree.node[tree.size+1].value=token[findTthId(idCount)].value;
							tree.node[tree.size+1].row=token[findTthId(idCount)].line;
							idCount++;
						}
						//num单独处理（把值、行数、类型填入）
						else if(g[k].right[i]==119) 
						{
							tree.node[tree.size+1].value=token[findTthNum(numCount)].value;
							tree.node[tree.size+1].row=token[findTthNum(numCount)].line;
							tree.node[tree.size+1].numType=token[findTthNum(numCount)].append;
							numCount++;
						}
						else if(g[k].right[i]==131 || g[k].right[i]==133)
						{
							tree.node[tree.size+1].value=token[findTthOp(opCount)].value;
							opCount++;
						}
						tree.size++;
			    	}
			    }
			}
			else
				return false;
		}
	}while(X!=$);
	return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
leaq 0x18(%rsp), %rbx
movl $0x8d, (%rbx)
leaq 0xa8958(%rip), %r14     # 0xba078
movq %r14, %rdi
movq %rbx, %rsi
callq 0x12f16
movl $0x0, (%rbx)
leaq 0x18(%rsp), %rsi
movq %r14, %rdi
callq 0x12f16
callq 0x11c63
movl $0x1, %r14d
leaq 0xb820(%rip), %rbp      # 0x1cf70
movq 0xa8951(%rip), %rax     # 0xba0a8
cmpq 0xa8952(%rip), %rax     # 0xba0b0
jne 0x11773
movq 0xa8959(%rip), %rax     # 0xba0c0
movq -0x8(%rax), %rax
movl $0x200, %ecx            # imm = 0x200
addq %rcx, %rax
movslq -0x4(%rax), %r15
movslq %r14d, %rax
imulq $0x38, %rax, %rax
movslq (%rbp,%rax), %rax
cmpq $0x64, %r15
jl 0x117a6
cmpl %eax, %r15d
jne 0x11c2f
leaq 0xa88df(%rip), %rdi     # 0xba078
callq 0x13172
incl %r14d
jmp 0x11c41
imulq $0xa8, %r15, %rcx
leaq 0xa6f2c(%rip), %rdx     # 0xb86e0
addq %rdx, %rcx
movslq -0x190(%rcx,%rax,4), %rbx
cmpq $-0x1, %rbx
je 0x11c52
movq %r15, 0x8(%rsp)
movl %r14d, 0x4(%rsp)
leaq 0xa889e(%rip), %rdi     # 0xba078
callq 0x13172
imulq $0xd0, %rbx, %rax
leaq 0xa30e3(%rip), %rcx     # 0xb48d0
leaq (%rcx,%rax), %rbx
leaq (%rax,%rcx), %r14
addq $0x8, %r14
movq $-0x1, %rax
movl $0x1, %ecx
movq %r14, %rdx
movq %rcx, %r12
movq %rdx, %r15
cmpl $-0x1, 0x8(%r14,%rax,4)
leaq 0x1(%rax), %rax
leaq 0x1(%rcx), %rcx
leaq 0x4(%rdx), %rdx
jne 0x11808
movq 0xa887f(%rip), %rax     # 0xba0a8
movq 0xa8888(%rip), %rcx     # 0xba0b8
addq $-0x4, %rcx
cmpq %rcx, %rax
je 0x1184b
movl (%r15), %ecx
movl %ecx, (%rax)
addq $0x4, %rax
movq %rax, 0xa885f(%rip)     # 0xba0a8
jmp 0x1185a
leaq 0xa8826(%rip), %rdi     # 0xba078
movq %r15, %rsi
callq 0x131be
addq $-0x4, %r15
decq %r12
jg 0x11822
xorl %edi, %edi
callq 0x11cf6
cltq
imulq $0xa8, %rax, %rax
leaq 0xa884e(%rip), %r9      # 0xba0c8
movl 0x5c(%rax,%r9), %ecx
cmpl 0x4(%rbx), %ecx
jne 0x11c23
movl (%r14), %esi
cmpl $-0x1, %esi
je 0x11c23
addq %r9, %rax
addq $0x8, %rax
movq %rax, 0x10(%rsp)
xorl %r12d, %r12d
movq %r14, %rbx
movl 0xa881c(%rip), %eax     # 0xba0c8
incl %eax
movq 0x10(%rsp), %rdi
movslq (%rdi), %rcx
leal 0x1(%rcx), %edx
movl %edx, (%rdi)
movl %eax, 0x4(%rdi,%rcx,4)
movslq 0xa8802(%rip), %rax     # 0xba0c8
imulq $0xa8, %rax, %rcx
movl %esi, 0x104(%rcx,%r9)
cmpl $0x64, %esi
jl 0x118ea
incq %rax
imulq $0xa8, %rax, %rax
movb $0x1, 0x60(%rax,%r9)
leaq 0x18(%rsp), %r13
movq %r13, %rdi
movq %r9, %r15
callq 0x11d66
movslq 0xa87c7(%rip), %rax     # 0xba0c8
imulq $0xa8, %rax, %rax
leaq (%rax,%r15), %rdi
addq $0x110, %rdi            # imm = 0x110
movq %r13, %rsi
callq 0x22a0
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x11937
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x2230
movl (%rbx), %eax
cmpl $0x82, %eax
jg 0x11a81
cmpl $0x65, %eax
leaq 0xa877a(%rip), %r9      # 0xba0c8
je 0x11af1
cmpl $0x77, %eax
jne 0x11c07
leaq 0xb5ec(%rip), %rax      # 0x1cf50
movl (%rax), %eax
movq $-0x1, %rbx
movq $-0x1, %rcx
testl %eax, %eax
jle 0x119ad
movl 0x2429f6(%rip), %edx    # 0x254374
leaq 0x38(%rbp), %rsi
incq %rax
xorl %edi, %edi
movl $0x1, %ecx
cmpl $0x77, (%rsi)
jne 0x11997
cmpl %edx, %edi
je 0x119aa
incl %edi
incq %rcx
addq $0x38, %rsi
cmpq %rcx, %rax
jne 0x1198c
movq $-0x1, %rcx
movslq %ecx, %rcx
imulq $0x38, %rcx, %rax
leaq (%rax,%rbp), %rsi
addq $0x8, %rsi
movslq 0xa8708(%rip), %rax     # 0xba0c8
imulq $0xa8, %rax, %rax
leaq (%rax,%r9), %rdi
addq $0x130, %rdi            # imm = 0x130
callq 0x2110
movl 0x242997(%rip), %eax    # 0x254374
leaq 0xb56c(%rip), %rcx      # 0x1cf50
movl (%rcx), %ecx
testl %ecx, %ecx
jle 0x11a1d
leaq 0x38(%rbp), %rsi
leaq 0x1(%rcx), %rdi
xorl %r8d, %r8d
movl $0x1, %edx
cmpl $0x77, (%rsi)
jne 0x11a07
cmpl %eax, %r8d
je 0x11a1a
incl %r8d
incq %rdx
addq $0x38, %rsi
cmpq %rdx, %rdi
jne 0x119fa
movq $-0x1, %rdx
movslq %edx, %rbx
imulq $0x38, %rbx, %rsi
movslq 0xa86a0(%rip), %rdx     # 0xba0c8
imulq $0xa8, %rdx, %rdi
movl 0x28(%rbp,%rsi), %esi
leaq 0xa868e(%rip), %r9      # 0xba0c8
movl %esi, 0x154(%rdi,%r9)
testl %ecx, %ecx
jle 0x11bdb
leaq 0x38(%rbp), %rdi
incq %rcx
xorl %r8d, %r8d
movl $0x1, %esi
cmpl $0x77, (%rdi)
jne 0x11a66
cmpl %eax, %r8d
je 0x11a79
incl %r8d
incq %rsi
addq $0x38, %rdi
cmpq %rsi, %rcx
jne 0x11a59
movq $-0x1, %rsi
movslq %esi, %rcx
jmp 0x11be2
cmpl $0x83, %eax
leaq 0xa863b(%rip), %r9      # 0xba0c8
je 0x11a9a
cmpl $0x85, %eax
jne 0x11c07
movl 0x2428d8(%rip), %edi    # 0x254378
callq 0x11ee7
cltq
imulq $0x38, %rax, %rax
leaq (%rax,%rbp), %rsi
addq $0x8, %rsi
movslq 0xa860e(%rip), %rax     # 0xba0c8
imulq $0xa8, %rax, %rax
leaq 0xa8600(%rip), %rcx     # 0xba0c8
leaq (%rax,%rcx), %rdi
addq $0x130, %rdi            # imm = 0x130
callq 0x2110
leaq 0xa85e9(%rip), %r9      # 0xba0c8
movl 0x242893(%rip), %eax    # 0x254378
leaq 0x24288c(%rip), %rcx    # 0x254378
jmp 0x11c03
leaq 0xb458(%rip), %rax      # 0x1cf50
movl (%rax), %eax
movq $-0x1, %rbx
movq $-0x1, %rcx
testl %eax, %eax
jle 0x11b41
movl 0x24285e(%rip), %edx    # 0x254370
leaq 0x38(%rbp), %rsi
incq %rax
xorl %edi, %edi
movl $0x1, %ecx
cmpl $0x65, (%rsi)
jne 0x11b2b
cmpl %edx, %edi
je 0x11b3e
incl %edi
incq %rcx
addq $0x38, %rsi
cmpq %rcx, %rax
jne 0x11b20
movq $-0x1, %rcx
movslq %ecx, %rcx
imulq $0x38, %rcx, %rax
leaq (%rax,%rbp), %rsi
addq $0x8, %rsi
movslq 0xa8574(%rip), %rax     # 0xba0c8
imulq $0xa8, %rax, %rax
leaq (%rax,%r9), %rdi
addq $0x130, %rdi            # imm = 0x130
callq 0x2110
movl 0x2427ff(%rip), %eax    # 0x254370
leaq 0xb3d8(%rip), %rcx      # 0x1cf50
movl (%rcx), %ecx
testl %ecx, %ecx
jle 0x11bad
leaq 0x38(%rbp), %rsi
incq %rcx
xorl %edi, %edi
movl $0x1, %edx
cmpl $0x65, (%rsi)
jne 0x11b97
cmpl %eax, %edi
je 0x11baa
incl %edi
incq %rdx
addq $0x38, %rsi
cmpq %rdx, %rcx
jne 0x11b8c
movq $-0x1, %rdx
movslq %edx, %rbx
imulq $0x38, %rbx, %rcx
movl 0x28(%rbp,%rcx), %ecx
movslq 0xa850c(%rip), %rdx     # 0xba0c8
imulq $0xa8, %rdx, %rdx
leaq 0xa84fe(%rip), %r9      # 0xba0c8
movl %ecx, 0x154(%rdx,%r9)
leaq 0x242797(%rip), %rcx    # 0x254370
jmp 0x11c03
movq $-0x1, %rcx
incq %rdx
imulq $0x38, %rcx, %rcx
movl 0x30(%rbp,%rcx), %ecx
imulq $0xa8, %rdx, %rdx
movl %ecx, 0xa8(%rdx,%r9)
leaq 0x242771(%rip), %rcx    # 0x254374
incl %eax
movl %eax, (%rcx)
incl 0xa84bb(%rip)           # 0xba0c8
leaq (%r14,%r12,4), %rbx
addq $0x4, %rbx
incq %r12
movl (%rbx), %esi
cmpl $-0x1, %esi
jne 0x118a6
movl 0x4(%rsp), %r14d
movq 0x8(%rsp), %r15
jmp 0x11c41
cmpl $0x6a, %r15d
jne 0x11c52
leaq 0xa843c(%rip), %rdi     # 0xba078
callq 0x13172
cmpl $0x8d, %r15d
jne 0x11750
movb $0x1, %al
jmp 0x11c54
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq