// File: /workspace/github_cpp_makefile_star2_O2/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 0xa8326(%rip), %r14     # 0xb4048
movq %r14, %rdi
movq %rbx, %rsi
callq 0xcf2e
andl $0x0, (%rbx)
leaq 0x18(%rsp), %rsi
movq %r14, %rdi
callq 0xcf2e
callq 0xc095
pushq $0x1
popq %rbp
leaq 0xb1f4(%rip), %r12      # 0x16f40
movq 0xa8325(%rip), %rax     # 0xb4078
cmpq 0xa8326(%rip), %rax     # 0xb4080
jne 0xbd6f
movq 0xa832d(%rip), %rax     # 0xb4090
movq -0x8(%rax), %rax
movl $0x200, %ecx            # imm = 0x200
addq %rcx, %rax
movslq -0x4(%rax), %r14
movslq %ebp, %rax
imulq $0x38, %rax, %rax
movslq (%r12,%rax), %rax
cmpq $0x64, %r14
jl 0xbda0
cmpl %eax, %r14d
jne 0xc061
leaq 0xa82b4(%rip), %rdi     # 0xb4048
callq 0xd188
incl %ebp
jmp 0xc073
imulq $0xa8, %r14, %rcx
leaq 0xa6902(%rip), %rdx     # 0xb26b0
addq %rdx, %rcx
movslq -0x190(%rcx,%rax,4), %r15
cmpq $-0x1, %r15
je 0xc084
movq %r14, 0x10(%rsp)
movl %ebp, 0xc(%rsp)
leaq 0xa8275(%rip), %rdi     # 0xb4048
callq 0xd188
imulq $0xd0, %r15, %rax
leaq 0xa2aba(%rip), %rcx     # 0xae8a0
leaq (%rcx,%rax), %r13
leaq (%rax,%rcx), %r15
addq $0x8, %r15
leaq 0xc(%rax,%rcx), %rax
pushq $-0x1
popq %rbp
incl %ebp
cmpl $-0x1, (%rax)
leaq 0x4(%rax), %rax
jne 0xbdfa
jmp 0xbe1b
movl %ebp, %eax
leaq (%r15,%rax,4), %rsi
leaq 0xa8234(%rip), %rdi     # 0xb4048
callq 0xd1de
decl %ebp
testl %ebp, %ebp
jns 0xbe07
xorl %edi, %edi
callq 0xc104
cltq
imulq $0xa8, %rax, %rax
leaq 0xa8262(%rip), %rbp     # 0xb4098
movl 0x5c(%rax,%rbp), %ecx
cmpl 0x4(%r13), %ecx
jne 0xc056
leaq (%rax,%rbp), %r13
addq $0x8, %r13
movl (%r15), %esi
cmpl $-0x1, %esi
je 0xc056
movl 0xa823a(%rip), %eax     # 0xb4098
incl %eax
movslq (%r13), %rcx
leal 0x1(%rcx), %edx
movl %edx, (%r13)
movl %eax, 0x4(%r13,%rcx,4)
movslq 0xa8221(%rip), %rax     # 0xb4098
imulq $0xa8, %rax, %rcx
movl %esi, 0x104(%rcx,%rbp)
cmpl $0x64, %esi
jl 0xbe99
incq %rax
imulq $0xa8, %rax, %rax
movb $0x1, 0x60(%rax,%rbp)
movq %rbx, %rdi
callq 0xc170
movslq 0xa81f0(%rip), %rax     # 0xb4098
imulq $0xa8, %rax, %rax
leaq (%rax,%rbp), %rdi
addq $0x110, %rdi            # imm = 0x110
movq %rbx, %rsi
callq 0x2230
movq %rbx, %rdi
callq 0x2388
movl (%r15), %eax
cmpl $0x85, %eax
je 0xbf65
cmpl $0x77, %eax
je 0xbfae
cmpl $0x83, %eax
je 0xbf65
cmpl $0x65, %eax
jne 0xc047
movl 0x242449(%rip), %edi    # 0x24e340
callq 0xc1da
cltq
imulq $0x38, %rax, %rax
leaq (%r12,%rax), %rsi
addq $0x8, %rsi
movslq 0xa8187(%rip), %rax     # 0xb4098
imulq $0xa8, %rax, %rax
leaq (%rax,%rbp), %rdi
addq $0x130, %rdi            # imm = 0x130
callq 0x2110
movq %rbp, %r14
movl 0x24240f(%rip), %ebp    # 0x24e340
movl %ebp, %edi
callq 0xc1da
cltq
imulq $0x38, %rax, %rax
movl 0x28(%r12,%rax), %eax
movslq 0xa814e(%rip), %rcx     # 0xb4098
imulq $0xa8, %rcx, %rcx
movl %eax, 0x154(%rcx,%r14)
leaq 0x2423e0(%rip), %rax    # 0x24e340
jmp 0xc03c
movl 0x2423dd(%rip), %edi    # 0x24e348
callq 0xc252
cltq
imulq $0x38, %rax, %rax
leaq (%r12,%rax), %rsi
addq $0x8, %rsi
movslq 0xa8113(%rip), %rax     # 0xb4098
imulq $0xa8, %rax, %rax
leaq (%rax,%rbp), %rdi
addq $0x130, %rdi            # imm = 0x130
callq 0x2110
movl 0x2423a6(%rip), %ebp    # 0x24e348
leaq 0x24239f(%rip), %rax    # 0x24e348
jmp 0xc03c
movl 0x242390(%rip), %edi    # 0x24e344
callq 0xc216
cltq
imulq $0x38, %rax, %rax
leaq (%r12,%rax), %rsi
addq $0x8, %rsi
movslq 0xa80ca(%rip), %rax     # 0xb4098
imulq $0xa8, %rax, %rax
leaq (%rax,%rbp), %rdi
addq $0x130, %rdi            # imm = 0x130
callq 0x2110
movq %rbp, %rbx
movl 0x242356(%rip), %ebp    # 0x24e344
movl %ebp, %edi
callq 0xc216
cltq
imulq $0x38, %rax, %rax
movl 0x28(%r12,%rax), %eax
movslq 0xa8091(%rip), %rcx     # 0xb4098
imulq $0xa8, %rcx, %r14
movl %eax, 0x154(%r14,%rbx)
movl %ebp, %edi
callq 0xc216
cltq
imulq $0x38, %rax, %rax
movl 0x30(%r12,%rax), %eax
movl %eax, 0x150(%r14,%rbx)
leaq 0x18(%rsp), %rbx
leaq 0x242308(%rip), %rax    # 0x24e344
incl %ebp
movl %ebp, (%rax)
leaq 0xa8051(%rip), %rbp     # 0xb4098
incl 0xa804b(%rip)           # 0xb4098
addq $0x4, %r15
jmp 0xbe4c
movl 0xc(%rsp), %ebp
movq 0x10(%rsp), %r14
jmp 0xc073
cmpl $0x6a, %r14d
jne 0xc084
leaq 0xa7fda(%rip), %rdi     # 0xb4048
callq 0xd188
cmpl $0x8d, %r14d
jne 0xbd4c
movb $0x1, %al
jmp 0xc086
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq