// File: /workspace/github_cpp_makefile_star2_O3/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 0xa7d9d(%rip), %r14     # 0xb9078
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1298e
movl $0x0, (%rbx)
leaq 0x18(%rsp), %rsi
movq %r14, %rdi
callq 0x1298e
callq 0x1183b
movl $0x1, %r14d
leaq 0xac65(%rip), %rbp      # 0x1bf70
movq 0xa7d96(%rip), %rax     # 0xb90a8
cmpq 0xa7d97(%rip), %rax     # 0xb90b0
jne 0x1132e
movq 0xa7d9e(%rip), %rax     # 0xb90c0
movq -0x8(%rax), %rax
movl $0x200, %ecx            # imm = 0x200
addq %rcx, %rax
movslq -0x4(%rax), %rbx
movslq %r14d, %rax
imulq $0x38, %rax, %rax
movslq (%rbp,%rax), %rax
cmpq $0x64, %rbx
jl 0x11360
cmpl %eax, %ebx
jne 0x11809
leaq 0xa7d25(%rip), %rdi     # 0xb9078
callq 0x12bea
incl %r14d
jmp 0x1181a
movq %rbx, 0x8(%rsp)
imulq $0xa8, %rbx, %rcx
leaq 0xa636d(%rip), %rdx     # 0xb76e0
addq %rdx, %rcx
movslq -0x190(%rcx,%rax,4), %rbx
cmpq $-0x1, %rbx
je 0x1182a
movl %r14d, 0x4(%rsp)
leaq 0xa7ce4(%rip), %rdi     # 0xb9078
callq 0x12bea
imulq $0xd0, %rbx, %rax
leaq 0xa2529(%rip), %rcx     # 0xb38d0
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 0x113c2
movq 0xa7cc5(%rip), %rax     # 0xb90a8
movq 0xa7cce(%rip), %rcx     # 0xb90b8
leaq -0x4(%rcx), %rdx
cmpq %rdx, %rax
je 0x11405
movl (%r15), %edx
movl %edx, (%rax)
addq $0x4, %rax
movq %rax, 0xa7ca5(%rip)     # 0xb90a8
jmp 0x11422
leaq 0xa7c6c(%rip), %rdi     # 0xb9078
movq %r15, %rsi
callq 0x12c36
movq 0xa7c8d(%rip), %rax     # 0xb90a8
movq 0xa7c96(%rip), %rcx     # 0xb90b8
addq $-0x4, %r15
decq %r12
jg 0x113ea
xorl %edi, %edi
callq 0x118ce
cltq
imulq $0xa8, %rax, %rax
leaq 0xa7c86(%rip), %r10     # 0xb90c8
movl 0x5c(%rax,%r10), %ecx
cmpl 0x4(%rbx), %ecx
jne 0x117fd
movl (%r14), %esi
cmpl $-0x1, %esi
je 0x117fd
addq %r10, %rax
addq $0x8, %rax
movq %rax, 0x10(%rsp)
movl 0xa7c5a(%rip), %eax     # 0xb90c8
xorl %r12d, %r12d
movq %r14, %rbx
incl %eax
movq 0x10(%rsp), %rdi
movslq (%rdi), %rcx
leal 0x1(%rcx), %edx
movl %edx, (%rdi)
movl %eax, 0x4(%rdi,%rcx,4)
movslq 0xa7c3a(%rip), %rax     # 0xb90c8
imulq $0xa8, %rax, %rcx
movl %esi, 0x104(%rcx,%r10)
cmpl $0x64, %esi
jl 0x114b2
incq %rax
imulq $0xa8, %rax, %rax
movb $0x1, 0x60(%rax,%r10)
leaq 0x18(%rsp), %r13
movq %r13, %rdi
movq %r10, %r15
callq 0x1193e
movslq 0xa7bff(%rip), %rax     # 0xb90c8
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 0x114ff
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x2230
movl (%rbx), %eax
cmpl $0x82, %eax
jg 0x115ec
cmpl $0x65, %eax
leaq 0xa7bb2(%rip), %r10     # 0xb90c8
je 0x1165c
cmpl $0x77, %eax
jne 0x117d9
leaq 0xaa24(%rip), %rax      # 0x1bf50
movl (%rax), %eax
movq $-0x1, %rbx
movq $-0x1, %rcx
testl %eax, %eax
jle 0x11572
movl 0x241e2e(%rip), %edx    # 0x253374
leaq 0x38(%rbp), %rsi
incq %rax
xorl %edi, %edi
movl $0x1, %ecx
cmpl $0x77, (%rsi)
jne 0x1155f
cmpl %edx, %edi
je 0x11572
incl %edi
incq %rcx
addq $0x38, %rsi
cmpq %rcx, %rax
jne 0x11554
movq $-0x1, %rcx
imulq $0x38, %rcx, %rax
leaq (%rax,%rbp), %rsi
addq $0x8, %rsi
movslq 0xa7b43(%rip), %rax     # 0xb90c8
imulq $0xa8, %rax, %rax
leaq (%rax,%r10), %rdi
addq $0x130, %rdi            # imm = 0x130
callq 0x2110
movl 0x241dd2(%rip), %eax    # 0x253374
leaq 0xa9a7(%rip), %rcx      # 0x1bf50
movl (%rcx), %ecx
testl %ecx, %ecx
jle 0x1171b
leaq 0x38(%rbp), %rdx
leaq 0x1(%rcx), %rsi
xorl %r8d, %r8d
movl $0x1, %edi
leaq 0xa7afe(%rip), %r10     # 0xb90c8
cmpl $0x77, (%rdx)
jne 0x115db
cmpl %eax, %r8d
je 0x11730
incl %r8d
incq %rdi
addq $0x38, %rdx
cmpq %rdi, %rsi
jne 0x115ca
jmp 0x11733
cmpl $0x83, %eax
leaq 0xa7ad0(%rip), %r10     # 0xb90c8
je 0x11605
cmpl $0x85, %eax
jne 0x117d9
movl 0x241d6d(%rip), %edi    # 0x253378
callq 0x11a3d
cltq
imulq $0x38, %rax, %rax
leaq (%rax,%rbp), %rsi
addq $0x8, %rsi
movslq 0xa7aa3(%rip), %rax     # 0xb90c8
imulq $0xa8, %rax, %rax
leaq 0xa7a95(%rip), %rcx     # 0xb90c8
leaq (%rax,%rcx), %rdi
addq $0x130, %rdi            # imm = 0x130
callq 0x2110
leaq 0xa7a7e(%rip), %r10     # 0xb90c8
movl 0x241d28(%rip), %eax    # 0x253378
leaq 0x241d21(%rip), %rcx    # 0x253378
jmp 0x117d5
leaq 0xa8ed(%rip), %rax      # 0x1bf50
movl (%rax), %eax
movq $-0x1, %rbx
movq $-0x1, %rcx
testl %eax, %eax
jle 0x116a9
movl 0x241cf3(%rip), %edx    # 0x253370
leaq 0x38(%rbp), %rsi
incq %rax
xorl %edi, %edi
movl $0x1, %ecx
cmpl $0x65, (%rsi)
jne 0x11696
cmpl %edx, %edi
je 0x116a9
incl %edi
incq %rcx
addq $0x38, %rsi
cmpq %rcx, %rax
jne 0x1168b
movq $-0x1, %rcx
imulq $0x38, %rcx, %rax
leaq (%rax,%rbp), %rsi
addq $0x8, %rsi
movslq 0xa7a0c(%rip), %rax     # 0xb90c8
imulq $0xa8, %rax, %rax
leaq (%rax,%r10), %rdi
addq $0x130, %rdi            # imm = 0x130
callq 0x2110
movl 0x241c97(%rip), %eax    # 0x253370
leaq 0xa870(%rip), %rcx      # 0x1bf50
movl (%rcx), %ecx
testl %ecx, %ecx
jle 0x11724
leaq 0x38(%rbp), %rdx
incq %rcx
xorl %edi, %edi
movl $0x1, %esi
leaq 0xa79cd(%rip), %r10     # 0xb90c8
cmpl $0x65, (%rdx)
jne 0x1170a
cmpl %eax, %edi
je 0x117ad
incl %edi
incq %rsi
addq $0x38, %rdx
cmpq %rsi, %rcx
jne 0x116fb
jmp 0x117b0
leaq 0xa79a6(%rip), %r10     # 0xb90c8
jmp 0x11733
leaq 0xa799d(%rip), %r10     # 0xb90c8
jmp 0x117b0
movq %rdi, %rbx
imulq $0x38, %rbx, %rsi
movslq 0xa798a(%rip), %rdx     # 0xb90c8
imulq $0xa8, %rdx, %rdi
movl 0x28(%rbp,%rsi), %esi
movl %esi, 0x154(%rdi,%r10)
movq $-0x1, %rsi
testl %ecx, %ecx
jle 0x1178a
leaq 0x38(%rbp), %rdi
incq %rcx
xorl %r9d, %r9d
movl $0x1, %r8d
cmpl $0x77, (%rdi)
jne 0x11779
cmpl %eax, %r9d
je 0x11787
incl %r9d
incq %r8
addq $0x38, %rdi
cmpq %r8, %rcx
jne 0x1176c
jmp 0x1178a
movq %r8, %rsi
incq %rdx
imulq $0x38, %rsi, %rcx
movl 0x30(%rbp,%rcx), %ecx
imulq $0xa8, %rdx, %rdx
movl %ecx, 0xa8(%rdx,%r10)
leaq 0x241bc9(%rip), %rcx    # 0x253374
jmp 0x117d5
movq %rsi, %rbx
imulq $0x38, %rbx, %rcx
movl 0x28(%rbp,%rcx), %ecx
movslq 0xa7909(%rip), %rdx     # 0xb90c8
imulq $0xa8, %rdx, %rdx
movl %ecx, 0x154(%rdx,%r10)
leaq 0x241b9b(%rip), %rcx    # 0x253370
incl %eax
movl %eax, (%rcx)
movl 0xa78e9(%rip), %eax     # 0xb90c8
incl %eax
movl %eax, 0xa78e1(%rip)     # 0xb90c8
leaq (%r14,%r12,4), %rbx
addq $0x4, %rbx
incq %r12
movl (%rbx), %esi
cmpl $-0x1, %esi
jne 0x11474
movl 0x4(%rsp), %r14d
movq 0x8(%rsp), %rbx
jmp 0x1181a
cmpl $0x6a, %ebx
jne 0x1182a
leaq 0xa7863(%rip), %rdi     # 0xb9078
callq 0x12bea
cmpl $0x8d, %ebx
jne 0x1130b
movb $0x1, %al
jmp 0x1182c
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq