// File: /workspace/github_cpp_makefile_star2_O1/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
movq %rdi, -0x50(%rbp)
movl $0x1, %edx
callq 0x2040
leaq -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x28(%r15), %rax
movq %rax, -0x58(%rbp)
leaq 0x1(%r14), %rax
movq %rax, -0x60(%rbp)
xorl %ebx, %ebx
movslq %ebx, %r13
movb 0x1(%r14,%r13), %al
movb %al, (%r15)
cmpb $0x24, (%r14,%r13)
je 0xb8a7
movq -0x40(%rbp), %rdx
leaq -0x48(%rbp), %rdi
xorl %esi, %esi
leaq 0x84f0(%rip), %rcx      # 0x1390e
xorl %r8d, %r8d
callq 0x22b0
movb (%r14,%r13), %al
addq %r14, %r13
cmpb $0x20, %al
jne 0xb443
movb 0x2(%r13), %al
movb %al, (%r15)
movb 0x1(%r13), %al
incq %r13
incl %ebx
jmp 0xb42d
cmpb $0x41, %al
jl 0xb501
cmpb $0x5b, %al
setl %cl
leal -0x61(%rax), %edx
cmpb $0x1a, %dl
setb %dl
orb %cl, %dl
cmpb $0x1, %dl
jne 0xb501
movslq %ebx, %rax
leaq (%r14,%rax), %r12
movb (%r14,%rax), %al
movl %ebx, %r13d
cmpb $0x41, %al
jl 0xb74a
cmpb $0x5b, %al
setb %cl
leal -0x61(%rax), %edx
cmpb $0x1a, %dl
setb %dl
orb %cl, %dl
je 0xb747
movsbl %al, %esi
leaq -0x48(%rbp), %rdi
callq 0x2190
movslq %ebx, %r13
movb 0x2(%r12), %al
movb %al, (%r15)
movb 0x1(%r14,%r13), %al
incq %r13
leal -0x30(%rax), %ecx
cmpb $0x9, %cl
ja 0xb4ee
movslq %r13d, %r12
addq -0x60(%rbp), %r12
leaq -0x48(%rbp), %r13
movsbl %al, %esi
movq %r13, %rdi
callq 0x2190
movslq %ebx, %rbx
movb 0x3(%r14,%rbx), %al
movb %al, (%r15)
movb (%r12), %al
leal -0x30(%rax), %ecx
incl %ebx
incq %r12
cmpb $0xa, %cl
jb 0xb4c2
incl %ebx
movl %ebx, %r13d
movslq %r13d, %rax
leaq (%r14,%rax), %r12
movb (%r14,%rax), %al
movl %r13d, %ebx
jmp 0xb472
leal -0x30(%rax), %ecx
cmpb $0x9, %cl
ja 0xb617
movslq %ebx, %r12
movb (%r14,%r12), %al
leal -0x30(%rax), %ecx
addq %r14, %r12
movl %ebx, %r13d
cmpb $0x9, %cl
ja 0xb549
movsbl %al, %esi
leaq -0x48(%rbp), %rdi
callq 0x2190
movb 0x2(%r12), %al
movb %al, (%r15)
movb 0x1(%r12), %al
incq %r12
leal -0x30(%rax), %ecx
incl %r13d
cmpb $0xa, %cl
jb 0xb522
leaq -0x90(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
addq %rsi, %rdx
leaq -0xa0(%rbp), %rdi
callq 0x4242
movq %r15, %rdi
leaq -0xa0(%rbp), %rsi
callq 0xb2e8
movl %eax, %ebx
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0xb597
callq 0x21b0
leaq -0xf0(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
addq %rsi, %rdx
leaq -0x100(%rbp), %rdi
callq 0x4242
leaq -0x100(%rbp), %rsi
callq 0xb95a
movslq 0xc2c(%r15), %rcx
leaq (%rcx,%rcx,2), %rcx
movq -0x58(%rbp), %rdx
movl %eax, -0x4(%rdx,%rcx,4)
movq -0x100(%rbp), %rdi
leaq -0xf0(%rbp), %rax
cmpq %rax, %rdi
je 0xb5f3
callq 0x21b0
movq -0x50(%rbp), %rdi
movl %ebx, %esi
callq 0x22f0
movl $0x1, %edx
movq %rax, %rdi
leaq 0x8300(%rip), %rsi      # 0x1390d
callq 0x2210
jmp 0xb7b7
movsbl %al, %r12d
movl %r12d, %esi
callq 0xb1ca
testb %al, %al
je 0xb690
leaq -0x48(%rbp), %rdi
movl %r12d, %esi
callq 0x2190
movzbl (%r13), %eax
cmpl $0x2d, %eax
je 0xb66d
cmpl $0x5b, %eax
je 0xb7c9
cmpl $0x3a, %eax
jne 0xb7e6
movb (%r15), %cl
cmpb $0x3d, %cl
je 0xb7d1
cmpl $0x5b, %eax
je 0xb7c9
cmpl $0x2d, %eax
jne 0xb7e6
movb (%r15), %cl
cmpb $0x3e, %cl
je 0xb7d1
xorb $0x5b, %al
movb (%r15), %cl
movl %ecx, %edx
xorb $0x5d, %dl
orb %al, %dl
je 0xb7d1
jmp 0xb7e6
leaq -0x48(%rbp), %rdi
leaq 0x8273(%rip), %rsi      # 0x1390e
callq 0x2080
testl %eax, %eax
je 0xb896
movq 0xd919(%rip), %rcx      # 0x18fc8
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq 0xd8fb(%rip), %rdi      # 0x18fc8
callq 0x2030
movq %rax, %rdi
callq 0x2140
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq %rax, %rdi
callq 0x2210
movq %rax, %r12
movl $0x24, %edx
movq %rax, %rdi
leaq 0x7df8(%rip), %rsi      # 0x134f4
callq 0x2210
movl 0xc28(%r15), %esi
movq %r12, %rdi
callq 0x22f0
movq 0xd8b1(%rip), %rcx      # 0x18fc8
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq 0xd893(%rip), %rdi      # 0x18fc8
callq 0x2030
movq %rax, %rdi
callq 0x2140
jmp 0xb896
movl %ebx, %r13d
leaq -0xb0(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
addq %rsi, %rdx
leaq -0xc0(%rbp), %rdi
callq 0x4242
movq %r15, %rdi
leaq -0xc0(%rbp), %rsi
callq 0xb234
movl %eax, %ebx
movq -0xc0(%rbp), %rdi
leaq -0xb0(%rbp), %rax
cmpq %rax, %rdi
je 0xb798
callq 0x21b0
movq -0x50(%rbp), %rdi
movl %ebx, %esi
callq 0x22f0
movl $0x1, %edx
movq %rax, %rdi
leaq 0x815b(%rip), %rsi      # 0x1390d
callq 0x2210
decl %r13d
movb (%r12), %al
movb %al, (%r15)
movl %r13d, %ebx
jmp 0xb896
movb (%r15), %cl
cmpb $0x5d, %cl
jne 0xb7e6
movsbl %cl, %esi
leaq -0x48(%rbp), %rdi
callq 0x2190
incl %ebx
movb 0x2(%r13), %al
movb %al, (%r15)
movslq %ebx, %rax
cmpb $0x5c, (%r14,%rax)
jne 0xb839
leaq -0xd0(%rbp), %rax
movq %rax, -0xe0(%rbp)
leaq -0xe0(%rbp), %r12
movq %r12, %rdi
leaq 0x7ab7(%rip), %rsi      # 0x132c6
leaq 0x7ab1(%rip), %rdx      # 0x132c7
callq 0x42dc
movq %r15, %rdi
movq %r12, %rsi
callq 0xb234
movl %eax, %r12d
movq -0xe0(%rbp), %rdi
leaq -0xd0(%rbp), %rax
jmp 0xb86c
leaq -0x70(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
addq %rsi, %rdx
leaq -0x80(%rbp), %rdi
callq 0x4242
movq %r15, %rdi
leaq -0x80(%rbp), %rsi
callq 0xb234
movl %eax, %r12d
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0xb876
callq 0x21b0
movq -0x50(%rbp), %rdi
movl %r12d, %esi
callq 0x22f0
movl $0x1, %edx
movq %rax, %rdi
leaq 0x807c(%rip), %rsi      # 0x1390d
callq 0x2210
leal 0x1(%rbx), %eax
cmpl $0xff, %ebx
movl %eax, %ebx
jl 0xb3f7
movq -0x50(%rbp), %rdi
callq 0x2270
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0xb8c2
callq 0x21b0
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xb92e
movq %rax, %rbx
movq -0xe0(%rbp), %rdi
leaq -0xd0(%rbp), %rax
jmp 0xb91c
jmp 0xb92e
movq %rax, %rbx
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
jmp 0xb91c
movq %rax, %rbx
movq -0xc0(%rbp), %rdi
leaq -0xb0(%rbp), %rax
jmp 0xb91c
movq %rax, %rbx
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0xb931
callq 0x21b0
jmp 0xb931
jmp 0xb92e
jmp 0xb92e
jmp 0xb92e
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0xb943
callq 0x21b0
movq %rbx, %rdi
callq 0x2310
nop