// File: /workspace/github_cpp_makefile_star2_O2/navrajsaini[P]PL_Compiler_design_project/scanner.cpp
// Function: Scanner::tokenLine(char*, int)
void Scanner::tokenLine(char now[], int y)
{
   out.open(tokenFileName.c_str(), ios::app);
   string token;
   int prnt, i, b=0;
   //TOKENLINE BLOCK 0
   for(i=0; i<=255; i++)
   {
      ahead=now[i+1];      
      if(isComment(now[i])==true)
      {
	 out.close();
	 return;
      }
      //wiping token for next iteration
      token="";
      while(isSpace(now[i])==true)
      {
	 i++;
	 ahead=now[i+1];
      }
      //TOKENLINE BLOCK 1
      if(isAlpha(now[i])==true)
      {
	 while(isAlpha(now[i])==true)
	 {
	    token.push_back(now[i]);
	    i++;
	    ahead=now[i+1];
	    //just incase there is a numeral inside the word
	    while(isNumeric(now[i])==true)
	    {
	       token.push_back(now[i]);
	       i++;
	       ahead=now[i+1];
	    }	    
	 }
	 //call to store token and move to next token, in this case an alpha
	 prnt = getToken(token);
	 out<<prnt<<" ";
	 i--;
	 ahead=now[i+1];
      }
      //TOKENLINE BLOCK 2
      else if(isNumeric(now[i])==true)
      {
	 while(isNumeric(now[i])==true)
	 {	    
	    token.push_back(now[i]);
	    i++;
	    ahead=now[i+1];	    
	 }
	 if(isAlpha(now[i]==true))
	 {	    
	    cout<<endl<<spellS(BADNAME)<<" on line:" ;
	    return;
	 }
	 //call to store token and move to next token, in this case a numeric
	 prnt = getNum(token);
	 //minus 1 becasue it was incrimnted inside getnum
	 lineToke[TN-1][2] = numericVAl(token);
	 out<<prnt<<" ";
	 i--;
	 ahead=now[i+1];
      }
      //TOKENLINE BLOCK 3
      else if(isSpecial(now[i])==true)
      {
	 token.push_back(now[i]);
	 if(now[i]==':'&&ahead=='=')
	 {
	    token.push_back(ahead);
	    i++;
	    ahead=now[i+1];	    
	 }
	 else if(now[i]=='-'&&ahead=='>')
	 {
	    token.push_back(ahead);
	    i++;
	    ahead=now[i+1];	    
	 }
	 else if(now[i]=='['&&ahead==']')
	 {
	    token.push_back(ahead);
	    i++;
	    ahead=now[i+1];
	    
	 }else
	 {
	 }
	 if(now[i]==92)
	 {
	    prnt = getToken("%");
	    out<<prnt<<" ";
	 }
	 else
	 {
	    //call to store token and move to next token, in this case an alpha
	    prnt = getToken(token);
	    out<<prnt<<" ";
	 }
      }
      //TOKENLINE BLOCK 4
      else if(token=="")
      {
	 //the case of if token is empty is the same as if now[i] is empty
	 //since token has not been initialised to anything from before.
      }
      else
      {	 
	 cout<<endl<<token<<" is a not identified token on line: "<<LN;
	 cout<<endl;
      }
      
   }
   out.close();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rsi, %r14
movq %rdi, %r15
addq $0xc30, %rdi            # imm = 0xC30
movq 0xe50(%r15), %rsi
pushq $0x1
popq %rdx
movq %rdi, -0x38(%rbp)
callq 0x2030
leaq -0x48(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x28(%r15), %rax
movq %rax, -0x60(%rbp)
xorl %r13d, %r13d
cmpl $0xff, %r13d
jg 0x8fb9
movslq %r13d, %rbx
movb 0x1(%r14,%rbx), %al
movb %al, (%r15)
cmpb $0x24, (%r14,%rbx)
je 0x8fb9
leaq -0x58(%rbp), %rdi
leaq 0x6c5b(%rip), %rsi      # 0xf8fe
callq 0x2310
leaq (%r14,%rbx), %r12
movb (%r14,%rbx), %al
cmpb $0x20, %al
jne 0x8cc7
movb 0x2(%r14,%rbx), %al
incq %rbx
movb %al, (%r15)
incl %r13d
incq %r12
jmp 0x8cac
cmpb $0x41, %al
jl 0x8d49
cmpb $0x5b, %al
setb %cl
leal -0x61(%rax), %edx
cmpb $0x1a, %dl
setb %dl
orb %cl, %dl
cmpb $0x1, %dl
jne 0x8d83
leaq -0x58(%rbp), %r13
movslq %ebx, %rax
leaq (%r14,%rax), %r12
movb (%r14,%rax), %al
cmpb $0x41, %al
jl 0x8eb6
cmpb $0x5b, %al
setb %cl
leal -0x61(%rax), %edx
cmpb $0x1a, %dl
setb %dl
orb %cl, %dl
cmpb $0x1, %dl
jne 0x8eb6
movsbl %al, %esi
movq %r13, %rdi
callq 0x2160
addq $0x2, %r12
incl %ebx
movb (%r12), %al
movb %al, (%r15)
movb -0x1(%r12), %al
leal -0x30(%rax), %ecx
cmpb $0x9, %cl
ja 0x8ce8
movsbl %al, %esi
movq %r13, %rdi
callq 0x2160
incq %r12
jmp 0x8d23
leal -0x30(%rax), %ecx
cmpb $0x9, %cl
ja 0x8d83
movl %r13d, %ebx
leaq -0x58(%rbp), %r13
leal -0x30(%rax), %ecx
cmpb $0x9, %cl
ja 0x8e33
movsbl %al, %esi
movq %r13, %rdi
callq 0x2160
movb 0x2(%r12), %al
movb %al, (%r15)
movb 0x1(%r12), %al
incq %r12
incl %ebx
jmp 0x8d58
movsbl %al, %r12d
movl %r12d, %esi
callq 0x8af8
testb %al, %al
je 0x8dd4
leaq -0x58(%rbp), %rdi
movl %r12d, %esi
callq 0x2160
movzbl (%r14,%rbx), %eax
cmpl $0x2d, %eax
je 0x8f15
cmpl $0x3a, %eax
leaq -0x58(%rbp), %rcx
je 0x8f0b
cmpl $0x5b, %eax
jne 0x8f3d
movb $0x5d, %al
cmpb $0x5d, (%r15)
je 0x8f21
jmp 0x8f3d
leaq -0x58(%rbp), %rdi
leaq 0x6b1f(%rip), %rsi      # 0xf8fe
callq 0x7926
testb %al, %al
jne 0x8faf
movq 0xc1d5(%rip), %rdi      # 0x14fc8
callq 0x20f0
movq %rax, %rdi
leaq -0x58(%rbp), %rsi
callq 0x2180
movq %rax, %rdi
leaq 0x66d6(%rip), %rsi      # 0xf4e4
callq 0x21a0
movl 0xc28(%r15), %esi
movq %rax, %rdi
callq 0x22c0
movq 0xc19f(%rip), %rdi      # 0x14fc8
callq 0x20f0
jmp 0x8faf
leaq -0xa0(%rbp), %rdi
movq %r13, %rsi
callq 0x2240
movq %r15, %rdi
leaq -0xa0(%rbp), %r13
movq %r13, %rsi
callq 0x8bc2
movl %eax, -0x2c(%rbp)
movq %r13, %rdi
callq 0x20d0
leaq -0x100(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x2240
leaq -0x100(%rbp), %r13
movq %r13, %rsi
callq 0x903c
movslq 0xc2c(%r15), %rcx
imulq $0xc, %rcx, %rcx
movq -0x60(%rbp), %rdx
movl %eax, -0x4(%rcx,%rdx)
movq %r13, %rdi
callq 0x20d0
movq -0x38(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0x22c0
movq %rax, %rdi
leaq 0x6a4e(%rip), %rsi      # 0xf8fd
callq 0x21a0
jmp 0x8efd
leaq -0xc0(%rbp), %rdi
movq %r13, %rsi
callq 0x2240
movq %r15, %rdi
leaq -0xc0(%rbp), %r13
movq %r13, %rsi
callq 0x8b5e
movl %eax, -0x2c(%rbp)
movq %r13, %rdi
callq 0x20d0
movq -0x38(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0x22c0
movq %rax, %rdi
leaq 0x6a05(%rip), %rsi      # 0xf8fd
callq 0x21a0
decl %ebx
movb (%r12), %al
movb %al, (%r15)
jmp 0x8faf
movb $0x3d, %al
cmpb $0x3d, (%r15)
je 0x8f21
jmp 0x8f3d
movb $0x3e, %al
cmpb $0x3e, (%r15)
leaq -0x58(%rbp), %rcx
jne 0x8f3d
movzbl %al, %esi
movq %rcx, %rdi
callq 0x2160
movb 0x2(%r14,%rbx), %al
leal 0x1(%rbx), %ecx
movb %al, (%r15)
movl %ecx, %ebx
leaq -0x58(%rbp), %rcx
movslq %ebx, %rax
cmpb $0x5c, (%r14,%rax)
jne 0x8f6e
leaq -0xe0(%rbp), %r13
movq %r13, %rdi
leaq 0x6372(%rip), %rsi      # 0xf2ca
leaq -0x2d(%rbp), %rdx
callq 0x20a0
movq %r15, %rdi
movq %r13, %rsi
callq 0x8b5e
jmp 0x8f89
leaq -0x80(%rbp), %rdi
movq %rcx, %rsi
callq 0x2240
movq %r15, %rdi
leaq -0x80(%rbp), %r13
movq %r13, %rsi
callq 0x8b5e
movl %eax, %r12d
movq %r13, %rdi
callq 0x20d0
movq -0x38(%rbp), %rdi
movl %r12d, %esi
callq 0x22c0
movq %rax, %rdi
leaq 0x6953(%rip), %rsi      # 0xf8fd
callq 0x21a0
incl %ebx
movl %ebx, %r13d
jmp 0x8c75
movq -0x38(%rbp), %rdi
callq 0x2250
leaq -0x58(%rbp), %rdi
callq 0x20d0
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x9019
movq %rax, %rbx
leaq -0xe0(%rbp), %rdi
jmp 0x900c
jmp 0x9019
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
jmp 0x900c
movq %rax, %rbx
leaq -0xc0(%rbp), %rdi
jmp 0x900c
movq %rax, %rbx
leaq -0xa0(%rbp), %rdi
callq 0x20d0
jmp 0x901c
jmp 0x9019
jmp 0x9019
jmp 0x9019
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x20d0
movq %rbx, %rdi
callq 0x22e0
nop