// File: /workspace/github_cpp_makefile_star2_O1/SeanLee97[P]LL1-Parser/grammar.cpp
// Function: Grammar::get_rule(char*, std::vector<bool, std::allocator<bool>>&)
vector<vector<int> > Grammar::get_rule(char* inputFile, vector<bool> &func_is_epsilon) {
	vector<vector<int> > temp_rules(num_rules, vector<int> (maxidx_terminal + num_nonterminals));

	int symbol_pos = 0;	// symbol 位置
	int line_pos = 0;  // line 位置
	string cur_symbol;

	input.open(inputFile);

	// skip terminal define
	while(getline(input, line)) {
		if(line.compare("") == 0) break;
	}

	// process rule
	while(getline(input, line)) {
		symbol_pos = 0;
		
		stringstream ss(line);

		getline(ss, cur_symbol, ' ');

		string left_side = cur_symbol;
		temp_rules[line_pos][symbol_pos] = _get_idx_by_symbol(cur_symbol);
		++symbol_pos;

		getline(ss, cur_symbol, ' ');
		if(ss.eof()) {
			// 导空符号的记录，Nonterminal -> epsilon 说明导空, 为true
			func_is_epsilon[_get_idx_by_symbol(left_side) - 1] = true;
		}
		while(getline(ss, cur_symbol, ' ')) {
			temp_rules[line_pos][symbol_pos] = _get_idx_by_symbol(cur_symbol);
			++symbol_pos; 
		}

		++line_pos;
	}
	input.close();

	return temp_rules;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x268, %rsp            # imm = 0x268
movq %rcx, -0xe0(%rbp)
movq %rdx, %r14
movq %rdi, %rbx
movslq 0x8(%rsi), %r12
movslq (%rsi), %rax
movq %rsi, -0x68(%rbp)
movslq 0x4(%rsi), %rsi
addq %rax, %rsi
leaq -0x288(%rbp), %rdi
leaq -0x58(%rbp), %rdx
callq 0x5e84
leaq -0x288(%rbp), %rdx
leaq -0x90(%rbp), %rcx
movq %rbx, -0x38(%rbp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x5f18
movq -0x288(%rbp), %rdi
testq %rdi, %rdi
je 0x2e7d
movq -0x278(%rbp), %rsi
subq %rdi, %rsi
callq 0x21d0
leaq -0x48(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq -0x68(%rbp), %rbx
leaq 0x10(%rbx), %rdi
movq %rdi, -0x60(%rbp)
movq %r14, %rsi
movl $0x8, %edx
callq 0x2120
leaq 0x218(%rbx), %rax
movq %rax, -0x30(%rbp)
leaq 0x5413(%rip), %r14      # 0x82ce
movq -0x60(%rbp), %rbx
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 0x2f00
movq -0x30(%rbp), %rdi
movq %r14, %rsi
callq 0x2090
testl %eax, %eax
jne 0x2ebf
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
leaq -0xf0(%rbp), %rbx
movq $0x0, -0x70(%rbp)
leaq -0x288(%rbp), %r15
leaq -0x100(%rbp), %r12
addq $0x3f, %rax
movq %rax, -0xd8(%rbp)
movq -0x60(%rbp), %r14
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %edx
movq %r14, %rdi
movq -0x30(%rbp), %rsi
callq 0x2300
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x31ad
movq %r15, %rdi
movq -0x30(%rbp), %rsi
movl $0x18, %edx
callq 0x2290
movq %r15, %rdi
leaq -0x58(%rbp), %rsi
movl $0x20, %edx
callq 0x2300
movq -0x68(%rbp), %r14
leaq -0x80(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
addq %rsi, %rdx
leaq -0x90(%rbp), %rdi
callq 0x6496
leaq -0xc0(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
addq %rsi, %rdx
leaq -0xd0(%rbp), %rdi
callq 0x6496
movq %r14, %rdi
leaq -0xd0(%rbp), %rsi
callq 0x32f0
movq -0x38(%rbp), %rcx
movq (%rcx), %rcx
movq -0x70(%rbp), %rdx
leaq (%rdx,%rdx,2), %r13
movq (%rcx,%r13,8), %rcx
movl %eax, (%rcx)
movq -0xd0(%rbp), %rdi
leaq -0xc0(%rbp), %rax
cmpq %rax, %rdi
je 0x301e
movq -0xc0(%rbp), %rsi
incq %rsi
callq 0x21d0
movq %r15, %rdi
leaq -0x58(%rbp), %rsi
movl $0x20, %edx
callq 0x2300
movq -0x288(%rbp), %rax
movq -0x18(%rax), %rax
testb $0x2, -0x268(%rbp,%rax)
je 0x30f2
leaq -0xa0(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x90(%rbp), %rsi
movq -0x88(%rbp), %rdx
addq %rsi, %rdx
leaq -0xb0(%rbp), %rdi
callq 0x6496
movq %r14, %rdi
leaq -0xb0(%rbp), %rsi
callq 0x32f0
movslq %eax, %rdx
leaq -0x1(%rdx), %rcx
addq $0x3e, %rdx
testq %rcx, %rcx
cmovnsq %rcx, %rdx
sarq $0x6, %rdx
shlq $0x3, %rdx
movq -0xe0(%rbp), %rsi
addq (%rsi), %rdx
andq -0xd8(%rbp), %rcx
xorl %esi, %esi
movabsq $-0x8000000000000000, %rdi # imm = 0x8000000000000000
cmpq %rdi, %rcx
setbe %sil
leal -0x1(%rax), %ecx
movl $0x1, %eax
shlq %cl, %rax
orq %rax, -0x8(%rdx,%rsi,8)
movq -0xb0(%rbp), %rdi
leaq -0xa0(%rbp), %rax
cmpq %rax, %rdi
je 0x30f2
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x21d0
movl $0x4, %r14d
movq %r15, %rdi
leaq -0x58(%rbp), %rsi
movl $0x20, %edx
callq 0x2300
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x316d
movq %rbx, -0x100(%rbp)
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x6496
movq -0x68(%rbp), %rdi
movq %r12, %rsi
callq 0x32f0
movq -0x38(%rbp), %rcx
movq (%rcx), %rcx
movq (%rcx,%r13,8), %rcx
movl %eax, (%rcx,%r14)
movq -0x100(%rbp), %rdi
cmpq %rbx, %rdi
je 0x3167
movq -0xf0(%rbp), %rsi
incq %rsi
callq 0x21d0
addq $0x4, %r14
jmp 0x30f8
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x3189
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x21d0
incq -0x70(%rbp)
movq %r15, %rdi
movq 0x7e21(%rip), %rsi      # 0xafb8
callq 0x2160
leaq -0x208(%rbp), %rdi
callq 0x20a0
jmp 0x2f32
movq %r14, %rdi
callq 0x2060
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x31ce
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x21d0
movq -0x38(%rbp), %rax
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq -0x288(%rbp), %rdi
testq %rdi, %rdi
je 0x32e7
movq -0x278(%rbp), %rsi
subq %rdi, %rsi
callq 0x21d0
jmp 0x32e7
movq %rax, %r14
jmp 0x32e7
jmp 0x3262
movq %rax, %r14
movq -0xb0(%rbp), %rdi
leaq -0xa0(%rbp), %rax
cmpq %rax, %rdi
je 0x328a
movq -0xa0(%rbp), %rsi
jmp 0x327d
jmp 0x3287
movq %rax, %r14
movq -0xd0(%rbp), %rdi
leaq -0xc0(%rbp), %rax
cmpq %rax, %rdi
je 0x328a
movq -0xc0(%rbp), %rsi
jmp 0x327d
jmp 0x3262
jmp 0x3259
movq %rax, %r14
jmp 0x32a6
jmp 0x3262
jmp 0x3287
movq %rax, %r14
jmp 0x32c5
movq %rax, %r14
movq -0x100(%rbp), %rdi
cmpq %rbx, %rdi
je 0x328a
movq -0xf0(%rbp), %rsi
incq %rsi
callq 0x21d0
jmp 0x328a
movq %rax, %r14
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x32a6
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x21d0
movq 0x7d0b(%rip), %rsi      # 0xafb8
leaq -0x288(%rbp), %rdi
callq 0x2160
leaq -0x208(%rbp), %rdi
callq 0x20a0
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x32de
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x21d0
movq -0x38(%rbp), %rdi
callq 0x2650
movq %r14, %rdi
callq 0x22e0
nop