// File: /workspace/github_cpp_makefile_star2_O3/matteorr[P]EarleyParser/EarleyParser.cpp
// Function: EarleyParser::createDictionary(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void EarleyParser::createDictionary( string filePath )
{
	string line;
	ifstream inputFile;

	inputFile.open( filePath.c_str(), fstream::in );

	if( inputFile.is_open() )
	{
		while( inputFile.good() )
		{
			/*
			 * reads a line (production) from the context free input grammar
			 */
			getline( inputFile, line );

			//skips empty line
			if( line.size() == 0 ) continue;

			cout << "[DEBUG]: " << line << endl;

			/*
			 * extracts tokens of the production
			 * separated by "->"
			 * first token is a word
			 * second token is the associated non terminal
			 */
			vector< string > tokenVector;
			this->splitToVector( line, &tokenVector, "->", false );

			//skips comment line
			if( tokenVector.at(0) == "#" ) continue;

			for( unsigned int i = 0; i < tokenVector.size(); i++ ){
				cout << "[DEBUG]: " << "line token: [" << tokenVector.at(i) << "]" << endl;
			}

			/*
			 * looks in the hash table of dictionary
			 * if the word was allready inserted
			 */
			EarleyParser::dictionaryHashTable::iterator got = this->earleyDictionary.find( tokenVector.at(0) );
			if( got != this->earleyDictionary.end() )
			{
				/*
				 * element found in hash table (key tokenVector->at(0) contained)
				 * error!
				 */

				cout << "[DEBUG]: BAD INPUT DICTIONARY!" << endl << endl;
				exit(1);
			}else{
				/*
				 * element not found in hash table (key tokenVector->at(0) not contained)
				 * save string in the hash map
				 */

				pair< string, string > element( tokenVector.at(0), tokenVector.at(1) );

				std::pair<EarleyParser::dictionaryHashTable::iterator, bool> insertionResult;
				insertionResult = this->earleyDictionary.insert( element );
				if( insertionResult.second == true ){
					/*
					 * element inserted with success
					 */
					cout << "[DEBUG]: [" << element.first << "][" << element.second << "] inserted with success" << endl << endl;
				}
			}

		}
		inputFile.close();

		for( dictionaryHashTable::iterator i = this->earleyDictionary.begin(); i != this->earleyDictionary.end(); i++ ){

			cout << "[DEBUG]: element [" << i->first << "][" << i->second << "] in dictionary" << endl;
		}

	}else{
		cout << "Error: not able to open input file [" << filePath << "]" << endl;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x298, %rsp            # imm = 0x298
movq %rsi, %r14
movq %rdi, %rbx
leaq -0x60(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq -0x2b8(%rbp), %rdi
callq 0x2210
movq (%r14), %rsi
leaq -0x2b8(%rbp), %rdi
movl $0x8, %edx
callq 0x2130
leaq -0x240(%rbp), %rdi
callq 0x2070
testb %al, %al
je 0x3776
leaq -0xa0(%rbp), %r15
leaq 0x48(%rbx), %rax
movq %rax, -0x50(%rbp)
movq 0xabb3(%rip), %r14      # 0xdfd8
leaq 0x6bf4(%rip), %r12      # 0xa020
movq $0x0, -0x48(%rbp)
movq -0x2b8(%rbp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, -0x298(%rbp,%rax)
jne 0x380f
leaq (%rax,%rbp), %rdi
addq $-0x2b8, %rdi           # imm = 0xFD48
movl $0xa, %esi
callq 0x21c0
movsbl %al, %edx
leaq -0x2b8(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x2310
cmpq $0x0, -0x68(%rbp)
je 0x3434
movl $0x9, %edx
movq %r14, %rdi
movq %r12, %rsi
callq 0x2220
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rdx
movq %r14, %rdi
callq 0x2220
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq %r13, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2150
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
movq $0x0, -0x30(%rbp)
movq %r15, -0xb0(%rbp)
leaq -0xb0(%rbp), %r13
movq %r13, %rdi
leaq 0x6b3d(%rip), %rsi      # 0xa02a
leaq 0x6b38(%rip), %rdx      # 0xa02c
callq 0x675a
leaq -0x70(%rbp), %rsi
leaq -0x40(%rbp), %rdx
movq %r13, %rcx
xorl %r8d, %r8d
callq 0x328e
movq -0xb0(%rbp), %rdi
cmpq %r15, %rdi
je 0x351d
callq 0x21a0
movq -0x40(%rbp), %rdi
cmpq %rdi, -0x38(%rbp)
je 0x38d3
leaq 0x6afb(%rip), %rsi      # 0xa02d
callq 0x20a0
testl %eax, %eax
je 0x3768
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rax
movq %rax, %rdx
subq %rsi, %rdx
je 0x360f
movl $0x1, %r15d
xorl %r13d, %r13d
movl $0x9, %edx
movq %r14, %rdi
movq %r12, %rsi
callq 0x2220
movl $0xd, %edx
movq %r14, %rdi
leaq 0x6ab4(%rip), %rsi      # 0xa02f
callq 0x2220
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rdx
subq %rax, %rdx
sarq $0x5, %rdx
cmpq %r13, %rdx
jbe 0x38c2
shlq $0x5, %r13
movq (%rax,%r13), %rsi
movq 0x8(%rax,%r13), %rdx
movq %r14, %rdi
callq 0x2220
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x6a7e(%rip), %rsi      # 0xa03d
callq 0x2220
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq %r13, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2150
movl %r15d, %r13d
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rax
movq %rax, %rdx
subq %rsi, %rdx
sarq $0x5, %rdx
incl %r15d
cmpq %r13, %rdx
ja 0x355c
jmp 0x3613
sarq $0x5, %rdx
cmpq %rsi, %rax
je 0x3936
movq -0x50(%rbp), %rdi
callq 0x6de0
leaq -0xa0(%rbp), %r15
testq %rax, %rax
jne 0x3900
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rax
movq %rax, %rdx
subq %rsi, %rdx
sarq $0x5, %rdx
cmpq %rsi, %rax
je 0x38ee
cmpq $0x2, %rdx
jb 0x38e5
leaq 0x20(%rsi), %rdx
leaq -0xb0(%rbp), %r13
movq %r13, %rdi
callq 0x6270
movq -0x50(%rbp), %rdi
movq %r13, %rsi
callq 0x6eec
testb $0x1, %dl
je 0x3742
movl $0xa, %edx
movq %r14, %rdi
leaq 0x6ae8(%rip), %rsi      # 0xa179
callq 0x2220
movq -0xb0(%rbp), %rsi
movq -0xa8(%rbp), %rdx
movq %r14, %rdi
callq 0x2220
movq %rax, %r13
movl $0x2, %edx
movq %rax, %rdi
leaq 0x6ac6(%rip), %rsi      # 0xa184
callq 0x2220
movq -0x90(%rbp), %rsi
movq -0x88(%rbp), %rdx
movq %r13, %rdi
callq 0x2220
movq %rax, %r13
movl $0x17, %edx
movq %rax, %rdi
leaq 0x6a9c(%rip), %rsi      # 0xa187
callq 0x2220
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq %r13, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2150
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq %r13, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2150
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x3757
callq 0x21a0
movq -0xb0(%rbp), %rdi
cmpq %r15, %rdi
je 0x3768
callq 0x21a0
leaq -0x40(%rbp), %rdi
callq 0x60b2
jmp 0x3434
movq 0xa85b(%rip), %rdi      # 0xdfd8
leaq 0x69b1(%rip), %rsi      # 0xa135
movl $0x24, %edx
callq 0x2220
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq 0xa83c(%rip), %rdi      # 0xdfd8
callq 0x2220
movq %rax, %rbx
leaq 0x6892(%rip), %rsi      # 0xa03d
movl $0x1, %edx
movq %rax, %rdi
callq 0x2220
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2150
leaq -0x2b8(%rbp), %rdi
callq 0x2080
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x37fd
callq 0x21a0
addq $0x298, %rsp            # imm = 0x298
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq -0x2b8(%rbp), %rdi
callq 0x2060
addq $0x58, %rbx
movq 0xa7b2(%rip), %r14      # 0xdfd8
leaq 0x6957(%rip), %r12      # 0xa184
leaq 0x697e(%rip), %r13      # 0xa1b2
movq (%rbx), %rbx
testq %rbx, %rbx
je 0x37df
movl $0x12, %edx
movq %r14, %rdi
leaq 0x6954(%rip), %rsi      # 0xa19f
callq 0x2220
movq 0x8(%rbx), %rsi
movq 0x10(%rbx), %rdx
movq %r14, %rdi
callq 0x2220
movq %rax, %r15
movl $0x2, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2220
movq 0x28(%rbx), %rsi
movq 0x30(%rbx), %rdx
movq %r15, %rdi
callq 0x2220
movq %rax, %r15
movl $0xf, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x2220
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2150
jmp 0x3834
leaq 0x6d4c(%rip), %rdi      # 0xa615
movq %r13, %rsi
xorl %eax, %eax
callq 0x2280
leaq 0x6d3b(%rip), %rdi      # 0xa615
xorl %esi, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x2280
movl $0x1, %eax
movq %rax, -0x48(%rbp)
leaq 0x6d20(%rip), %rdi      # 0xa615
movq -0x48(%rbp), %rsi
xorl %eax, %eax
callq 0x2280
movq 0xa6d1(%rip), %rdi      # 0xdfd8
leaq 0x684c(%rip), %rsi      # 0xa15a
movl $0x1e, %edx
callq 0x2220
movq 0xa6b9(%rip), %rdi      # 0xdfd8
callq 0x20f0
movq %rax, %rdi
callq 0x20f0
movl $0x1, %edi
callq 0x2230
leaq 0x6cd8(%rip), %rdi      # 0xa615
xorl %esi, %esi
xorl %eax, %eax
callq 0x2280
movq %rax, %rbx
jmp 0x39a5
jmp 0x3988
jmp 0x398d
jmp 0x3973
jmp 0x398d
movq %rax, %rbx
movq -0xb0(%rbp), %rdi
cmpq %r15, %rdi
je 0x3990
callq 0x21a0
jmp 0x3990
jmp 0x398d
jmp 0x398d
jmp 0x398d
jmp 0x398d
jmp 0x3988
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
callq 0x62d8
jmp 0x3990
jmp 0x3988
jmp 0x398d
movq %rax, %rbx
jmp 0x3999
movq %rax, %rbx
leaq -0x40(%rbp), %rdi
callq 0x60b2
leaq -0x2b8(%rbp), %rdi
callq 0x2080
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x39b7
callq 0x21a0
movq %rbx, %rdi
callq 0x22f0
nop