// File: /workspace/github_cpp_makefile_star2_O1/SeanLee97[P]LL1-Parser/grammar.cpp
// Function: Grammar::_grammar_counter(char*)
void Grammar::_grammar_counter(char* inputFile) {
	input.open(inputFile);
	// 获取出现次数最多的字符
	string cur_maxfreq_terminals;

	while(getline(input, line)){
		if(line.compare("") == 0) break;

		stringstream ss(line);

		getline(ss, cur_maxfreq_terminals, ' ');
		getline(ss, cur_maxfreq_terminals, ' ');
		// 最大id-terminal
		// atoi字符串转换成整型数的一个函数
		maxidx_terminal = atoi(cur_maxfreq_terminals.c_str());
	}

	string last_unique_nonterminal(""); 
	string this_nonterminal;

	while(getline(input, line)) {
		stringstream ss(line); 
		getline(ss, this_nonterminal, ' ');

		if(this_nonterminal.compare(last_unique_nonterminal) != 0) {
			++num_nonterminals;
			last_unique_nonterminal = this_nonterminal;
		}

		++num_rules;
	}

	input.close();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1f8, %rsp            # imm = 0x1F8
movq %rdi, %r14
leaq 0x10(%rdi), %rbx
movq %rbx, %rdi
movl $0x8, %edx
callq 0x2120
leaq -0x80(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x218(%r14), %rax
movq %rax, -0x30(%rbp)
leaq -0x218(%rbp), %r12
leaq -0x90(%rbp), %r13
movq -0x30(%rbp), %r15
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %edx
movq %rbx, %rdi
movq -0x30(%rbp), %rsi
callq 0x2300
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x49c5
movq %r15, %rdi
leaq 0x3971(%rip), %rsi      # 0x82ce
callq 0x2090
testl %eax, %eax
je 0x49c5
movq %r12, %rdi
movq %r15, %rsi
movl $0x18, %edx
callq 0x2290
movq %r12, %rdi
movq %r13, %rsi
movl $0x20, %edx
callq 0x2300
movq %r12, %rdi
movq %r13, %rsi
movl $0x20, %edx
callq 0x2300
movq -0x90(%rbp), %rdi
callq 0x2280
movl %eax, (%r14)
movq %r12, %rdi
movq 0x6609(%rip), %rsi      # 0xafb8
callq 0x2160
leaq -0x198(%rbp), %rdi
callq 0x20a0
jmp 0x4922
leaq -0x60(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x38fa(%rip), %rdx      # 0x82ce
leaq -0x70(%rbp), %rdi
movq %rdx, %rsi
callq 0x2d10
leaq -0x40(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq -0x218(%rbp), %r12
movq -0x30(%rbp), %r15
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2300
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x4acb
movq %r12, %rdi
movq %r15, %rsi
movl $0x18, %edx
callq 0x2290
movq %r12, %r15
movq %r12, %rdi
leaq -0x50(%rbp), %rsi
movl $0x20, %edx
callq 0x2300
movq %r14, %r13
movq -0x48(%rbp), %r12
movq -0x68(%rbp), %r14
cmpq %r12, %r14
movq %r12, %rdx
cmovbq %r14, %rdx
testq %rdx, %rdx
je 0x4a84
movq -0x70(%rbp), %rsi
movq -0x50(%rbp), %rdi
callq 0x21e0
testl %eax, %eax
sete %al
jmp 0x4a86
movb $0x1, %al
cmpq %r14, %r12
sete %cl
testb %cl, %al
movq %r13, %r14
jne 0x4aa4
incl 0x4(%r14)
leaq -0x70(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x2100
incl 0x8(%r14)
movq %r15, %r12
movq %r15, %rdi
movq 0x6503(%rip), %rsi      # 0xafb8
callq 0x2160
leaq -0x198(%rbp), %rdi
callq 0x20a0
jmp 0x49fa
movq %rbx, %rdi
callq 0x2060
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x4aec
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x21d0
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x4b05
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x21d0
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x4b21
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x21d0
addq $0x1f8, %rsp            # imm = 0x1F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4b88
jmp 0x4b5f
jmp 0x4b5f
movq %rax, %rbx
movq 0x6475(%rip), %rsi      # 0xafb8
leaq -0x218(%rbp), %rdi
callq 0x2160
leaq -0x198(%rbp), %rdi
callq 0x20a0
jmp 0x4bbd
jmp 0x4b88
movq %rax, %rbx
jmp 0x4bbd
movq %rax, %rbx
movq 0x644a(%rip), %rsi      # 0xafb8
leaq -0x218(%rbp), %rdi
callq 0x2160
leaq -0x198(%rbp), %rdi
callq 0x20a0
jmp 0x4b8b
movq %rax, %rbx
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x4ba4
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x21d0
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x4bbd
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x21d0
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x4bd9
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x21d0
movq %rbx, %rdi
callq 0x22e0
nop