// File: /workspace/github_cpp_makefile_star2_O2/zhengwangsun[P]pas2c/grammar.cpp
// Function: GrammarOutput()
void GrammarOutput(void)                  //输出语法分析的中间结果 
{
	ofstream fp("GrammarOut.txt");
	if(!fp)
	{
		cout<<"文法写入文件失败!"<<endl;
	}
	else
	{
		fp<<endl;
		fp<<"   输出说明："<<endl<<endl;
		fp<<"   1.此txt输出的是文法生成式以及FIRST集和FOLLOW集；"<<endl<<endl;
		fp<<"   2.FIRST部分输出的是每一个生成式右部符号串的FIRST集；"<<endl<<endl;
		fp<<"   3.FOLLOW部分输出的是生成式左部非终结符的FOLLOW集。"<<endl<<endl<<endl<<endl; 
	}
	fp<<"**************************文法生成式及FIRST、FOLLOW集**************************"<<endl<<endl;
	for(int i=0;i<GenerationNum;i++)
	{
		fp<<" ("<<i<<"): ";
		for(int j=0;j<VNnum;j++)	
		{
	  		if(g[i].left==vn[j].value)
	  		{
	  			fp<<vn[j].name;
	  			break;
			}
		}
		fp<<" -> ";
		int k=0;
		while(g[i].right[k]!=-1)
		{
	  		if(g[i].right[k]<100)
	  	  	{
				for(int j=0;j<VNnum;j++)
	  			{
	  	  			if(g[i].right[k]==vn[j].value)
	  	  			{
	  	  	  			fp<<vn[j].name<<" ";
	  	  	  			break;
					}
				}
			}
			else
			{
				for(int j=100;j<100+VTnum;j++)
	  			{
	  	  			if(g[i].right[k]==vt[j-100].value)
	  	  			{
	  	  				fp<<vt[j-100].name<<" ";
	  	  	  			break;
			  		}
		  		}
			}
	  	k++;	  
		}
		fp<<endl;
		fp<<"   FIRST : ";
		int m=0;
		while(g[i].FIRST[m]!=-1)
		{
			for(int k=0;k<VTnum;k++)
			{
				if(vt[k].value==g[i].FIRST[m])
					fp<<vt[k].name<<" ";
			}
			m++;
		}
		fp<<endl;
		fp<<"   FOLLOW: ";
		for(int m=0;m<FOLLOWnum;m++)
		{
			if(g[i].FOLLOW[m]==$)
				fp<<"$ ";
			else
			{
				for(int k=0;k<VTnum;k++)
				{
					if(vt[k].value==g[i].FOLLOW[m])
						fp<<vt[k].name<<" ";
				}
			}	
		}
		fp<<endl;
		fp<<endl;
	}
	fp<<"*******************************************************************************"<<endl; 
	fp.close();
	
	ofstream fp1("AnalysisTable.txt");
	if(!fp1)
	{
		cout<<"分析表写入文件失败!"<<endl;
	}
	else
	{
		fp1<<endl;
		fp1<<"   输出说明："<<endl<<endl;
		fp1<<"   1.此txt输出的是文法的LL(1)分析表；"<<endl<<endl;
		fp1<<"   2.横向第一行输出的是终结符的编号以及 $；"<<endl<<endl;
		fp1<<"   3.纵向第一列输出的是非终结符的编号；"<<endl<<endl;
		fp1<<"   4.-1代表此处为空，其他值代表的是生成式的编号(0～75)。"<<endl<<endl<<endl;
	}
	fp1<<endl<<"\t";
	for(int j=0;j<VTnum;j++)
		fp1<<j+100<<"\t";
	fp1<<"$"<<"\t"<<endl<<endl;
	for(int i=0;i<VNnum;i++)
	{
		fp1<<i<<"\t";
		for(int j=0;j<VTnum+1;j++)
		{
			fp1<<AnalysisTable[i][j]<<"\t";
		}
		fp1<<endl<<endl;
	}
	fp1.close();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x408, %rsp            # imm = 0x408
leaq 0x3ab3(%rip), %rsi      # 0xf229
leaq 0x208(%rsp), %rbx
pushq $0x10
popq %rdx
movq %rbx, %rdi
callq 0x2200
movq (%rbx), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x228(%rsp,%rax)
je 0xb7b2
movq 0x882f(%rip), %rdi      # 0x13fd0
leaq 0x3a90(%rip), %rsi      # 0xf238
callq 0x21d0
jmp 0xb857
leaq 0x208(%rsp), %rdi
callq 0x20f0
leaq 0x3a8c(%rip), %rsi      # 0xf252
leaq 0x208(%rsp), %rdi
callq 0x21d0
movq %rax, %rdi
callq 0x20f0
movq %rax, %rdi
callq 0x20f0
leaq 0x3a7b(%rip), %rsi      # 0xf265
leaq 0x208(%rsp), %rdi
callq 0x21d0
movq %rax, %rdi
callq 0x20f0
movq %rax, %rdi
callq 0x20f0
leaq 0x3a9b(%rip), %rsi      # 0xf2a9
leaq 0x208(%rsp), %rdi
callq 0x21d0
movq %rax, %rdi
callq 0x20f0
movq %rax, %rdi
callq 0x20f0
leaq 0x3ac3(%rip), %rsi      # 0xf2f5
leaq 0x208(%rsp), %rdi
callq 0x21d0
movq %rax, %rdi
callq 0x20f0
movq %rax, %rdi
callq 0x20f0
movq %rax, %rdi
callq 0x20f0
movq %rax, %rdi
callq 0x20f0
leaq 0x3ad7(%rip), %rsi      # 0xf33d
leaq 0x208(%rsp), %rdi
callq 0x21d0
movq %rax, %rdi
callq 0x20f0
movq %rax, %rdi
callq 0x20f0
xorl %r14d, %r14d
leaq 0x208(%rsp), %r15
leaq 0x2430db(%rip), %rbx    # 0x24e970
leaq 0x2d25(%rip), %r13      # 0xe5c1
cmpq $0x4c, %r14
je 0xba85
movq %r15, %rdi
leaq 0x3ae5(%rip), %rsi      # 0xf395
callq 0x21d0
movq %rax, %rdi
movl %r14d, %esi
callq 0x2320
movq %rax, %rdi
leaq 0x3ace(%rip), %rsi      # 0xf398
callq 0x21d0
imulq $0xd0, %r14, %r12
leaq 0xa2fc3(%rip), %rax     # 0xae8a0
movl 0x4(%r12,%rax), %eax
leaq 0x242a3f(%rip), %rcx    # 0x24e328
pushq $0x28
popq %rdx
decq %rdx
je 0xb905
leaq 0x28(%rcx), %rsi
cmpl 0x48(%rcx), %eax
movq %rsi, %rcx
jne 0xb8ec
movq %r15, %rdi
callq 0x21c0
movq %r15, %rdi
leaq 0x3913(%rip), %rsi      # 0xf222
callq 0x21d0
movq %r14, (%rsp)
leaq 0xa2f81(%rip), %rax     # 0xae8a0
addq %rax, %r12
xorl %r14d, %r14d
movl 0x8(%r12,%r14,4), %eax
cmpl $-0x1, %eax
je 0xb997
cmpl $0x64, %eax
jge 0xb964
leaq 0x2429ed(%rip), %rcx    # 0x24e328
pushq $0x28
popq %rdx
decq %rdx
je 0xb992
leaq 0x28(%rcx), %rsi
cmpl 0x48(%rcx), %eax
movq %rsi, %rcx
jne 0xb93e
movq %r15, %rdi
callq 0x21c0
movq %rax, %rdi
movq %r13, %rsi
callq 0x21d0
jmp 0xb992
leaq 0x242fdd(%rip), %rcx    # 0x24e948
pushq $0x2a
popq %rdx
decq %rdx
je 0xb992
leaq 0x28(%rcx), %rsi
cmpl 0x48(%rcx), %eax
movq %rsi, %rcx
jne 0xb96e
movq %r15, %rdi
callq 0x21c0
movq %rax, %rdi
movq %r13, %rsi
callq 0x21d0
incq %r14
jmp 0xb925
movq %r15, %rdi
callq 0x20f0
movq %r15, %rdi
leaq 0x39f3(%rip), %rsi      # 0xf39c
callq 0x21d0
xorl %r14d, %r14d
cmpl $-0x1, 0x30(%r12,%r14,4)
je 0xb9f1
xorl %ebp, %ebp
cmpq $0x668, %rbp            # imm = 0x668
je 0xb9ec
movl 0x20(%rbp,%rbx), %eax
cmpl 0x30(%r12,%r14,4), %eax
jne 0xb9e6
leaq (%rbx,%rbp), %rsi
movq %r15, %rdi
callq 0x21c0
movq %rax, %rdi
movq %r13, %rsi
callq 0x21d0
addq $0x28, %rbp
jmp 0xb9bb
incq %r14
jmp 0xb9b1
movq %r15, %rdi
callq 0x20f0
movq %r15, %rdi
leaq 0x39a5(%rip), %rsi      # 0xf3a8
callq 0x21d0
xorl %r14d, %r14d
cmpq $0x14, %r14
je 0xba69
cmpl $0x8d, 0x80(%r12,%r14,4)
jne 0xba33
movq %r15, %rdi
leaq 0x398b(%rip), %rsi      # 0xf3b4
callq 0x21d0
incq %r14
jmp 0xba0b
xorl %ebp, %ebp
cmpq $0x668, %rbp            # imm = 0x668
je 0xba2e
movl 0x20(%rbp,%rbx), %eax
cmpl 0x80(%r12,%r14,4), %eax
jne 0xba63
leaq (%rbx,%rbp), %rsi
movq %r15, %rdi
callq 0x21c0
movq %rax, %rdi
movq %r13, %rsi
callq 0x21d0
addq $0x28, %rbp
jmp 0xba35
movq %r15, %rdi
callq 0x20f0
movq %r15, %rdi
callq 0x20f0
movq (%rsp), %r14
incq %r14
jmp 0xb89c
leaq 0x392b(%rip), %rsi      # 0xf3b7
leaq 0x208(%rsp), %rdi
callq 0x21d0
movq %rax, %rdi
callq 0x20f0
leaq 0x208(%rsp), %rdi
callq 0x2270
leaq 0x3952(%rip), %rsi      # 0xf407
leaq 0x8(%rsp), %rdi
pushq $0x10
popq %rdx
callq 0x2200
movq 0x8(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x28(%rsp,%rax)
je 0xbaea
movq 0x84f7(%rip), %rdi      # 0x13fd0
leaq 0x3939(%rip), %rsi      # 0xf419
callq 0x21d0
jmp 0xbb99
leaq 0x8(%rsp), %rdi
callq 0x20f0
leaq 0x3757(%rip), %rsi      # 0xf252
leaq 0x8(%rsp), %rdi
callq 0x21d0
movq %rax, %rdi
callq 0x20f0
movq %rax, %rdi
callq 0x20f0
leaq 0x391a(%rip), %rsi      # 0xf436
leaq 0x8(%rsp), %rdi
callq 0x21d0
movq %rax, %rdi
callq 0x20f0
movq %rax, %rdi
callq 0x20f0
leaq 0x392b(%rip), %rsi      # 0xf468
leaq 0x8(%rsp), %rdi
callq 0x21d0
movq %rax, %rdi
callq 0x20f0
movq %rax, %rdi
callq 0x20f0
leaq 0x3948(%rip), %rsi      # 0xf4a6
leaq 0x8(%rsp), %rdi
callq 0x21d0
movq %rax, %rdi
callq 0x20f0
movq %rax, %rdi
callq 0x20f0
leaq 0x3960(%rip), %rsi      # 0xf4df
leaq 0x8(%rsp), %rdi
callq 0x21d0
movq %rax, %rdi
callq 0x20f0
movq %rax, %rdi
callq 0x20f0
movq %rax, %rdi
callq 0x20f0
leaq 0x8(%rsp), %rdi
callq 0x20f0
leaq 0x27f1(%rip), %rsi      # 0xe3a3
movq %rax, %rdi
callq 0x21d0
xorl %r15d, %r15d
pushq $0x29
popq %rbp
leaq 0x8(%rsp), %rbx
leaq 0x27d7(%rip), %r14      # 0xe3a3
subl $0x1, %ebp
jb 0xbbed
leal 0x64(%r15), %esi
movq %rbx, %rdi
callq 0x2320
movq %rax, %rdi
movq %r14, %rsi
callq 0x21d0
incl %r15d
jmp 0xbbcc
leaq 0x3633(%rip), %rsi      # 0xf227
leaq 0x8(%rsp), %rdi
callq 0x21d0
leaq 0x279e(%rip), %rsi      # 0xe3a3
movq %rax, %rdi
callq 0x21d0
movq %rax, %rdi
callq 0x20f0
movq %rax, %rdi
callq 0x20f0
leaq 0xa6a8c(%rip), %r12     # 0xb26b0
xorl %ebx, %ebx
leaq 0x8(%rsp), %r14
leaq 0x2771(%rip), %r15      # 0xe3a3
cmpq $0x27, %rbx
je 0xbc8e
movq %r14, %rdi
movl %ebx, %esi
callq 0x2320
movq %rax, %rdi
movq %r15, %rsi
callq 0x21d0
xorl %r13d, %r13d
cmpq $0x2a, %r13
je 0xbc72
movl (%r12,%r13,4), %esi
movq %r14, %rdi
callq 0x2320
movq %rax, %rdi
movq %r15, %rsi
callq 0x21d0
incq %r13
jmp 0xbc50
movq %r14, %rdi
callq 0x20f0
movq %rax, %rdi
callq 0x20f0
incq %rbx
addq $0xa8, %r12
jmp 0xbc32
leaq 0x8(%rsp), %rdi
callq 0x2270
leaq 0x8(%rsp), %rdi
callq 0x22a0
leaq 0x208(%rsp), %rdi
callq 0x22a0
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xbcea
jmp 0xbcea
jmp 0xbcd9
jmp 0xbcea
jmp 0xbcd9
jmp 0xbcea
jmp 0xbcd9
jmp 0xbcea
jmp 0xbcea
jmp 0xbcea
jmp 0xbcea
jmp 0xbcea
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x22a0
jmp 0xbced
jmp 0xbcea
movq %rax, %rbx
leaq 0x208(%rsp), %rdi
callq 0x22a0
movq %rbx, %rdi
callq 0x2330