// File: menhits[P]phplus/src/Lexer.cpp
// Function: lexString(std::shared_ptr<SourceFile>, std::vector<std::shared_ptr<TokenData>, std::allocator<std::shared_ptr<TokenData>>>&)
void lexString(shared_ptr<SourceFile> file, vector<Token>& tokens)
{
	string tokenTxt;
	int line=1;
	int charPos=1;
	
	TokenData::Type type=TokenData::WHITESPACE;
	
	for (int i=0; i<file->size(); i++)
	{
		CharClassifier::Type charType=charClassifier.get(file, i);
		TokenData::Type newType=CharClassifier::getTokenType(charType, type);
		
		if (newType!=type)
		{
			if (!tokenTxt.empty())
			{
				if (type==TokenData::OPERATOR)
				{
					vector<Operator> opMatches;
					ops->get(tokenTxt, opMatches);
					
					for (auto op: opMatches)
					{
						tokens.push_back(makeToken(op->getText(), file, line, charPos-tokenTxt.size(), type, op));
					}
				}
				else if (type==TokenData::LINE_COMMENT || type==TokenData::BLOCK_COMMENT)
				{
					// do nothing
				}
				else
				{
					Token token=makeToken(tokenTxt, file, line, charPos-tokenTxt.size(), type);
					
					if (type==TokenData::UNKNOWN)
					{
						PhplusError("invalid token '"+tokenTxt+"'", SOURCE_ERROR, token).log();
					}
					else
					{
						tokens.push_back(token);
					}
				}
			}
			tokenTxt="";
		}
		
		if (newType!=TokenData::WHITESPACE && newType!=TokenData::LINE_END)
		{
			if (newType==TokenData::STRING_LITERAL && (*file)[i]=='\\')
			{
				i++;
				if ((*file)[i]=='n')
					tokenTxt+='\n';
				else if ((*file)[i]=='"')
					tokenTxt+='"';
				else if ((*file)[i]=='t')
					tokenTxt+='\t';
				else if ((*file)[i]=='\\')
					tokenTxt+='\\';
				else
					throw PhplusError(string()+"invalid escape character '\\"+(*file)[i]+"'", SOURCE_ERROR, makeToken(tokenTxt+(*file)[i], file, line, charPos-tokenTxt.size(), type));
			}
			else
			{
				tokenTxt+=(*file)[i];
			}
		}
		
		type=newType;
		
		if ((*file)[i]=='\n')
		{
			line++;
			charPos=1;
		}
		else
		{
			charPos++;
		}
	}
}

// Assembly:
subq $0x3a8, %rsp            # imm = 0x3A8
movq %rdi, 0xd8(%rsp)
movq %rdi, 0x3a0(%rsp)
movq %rsi, 0x398(%rsp)
leaq 0x378(%rsp), %rdi
callq 0xb4e0
movl $0x1, 0x374(%rsp)
movl $0x1, 0x370(%rsp)
movl $0x0, 0x36c(%rsp)
movl $0x0, 0x368(%rsp)
movq 0xd8(%rsp), %rdi
movl 0x368(%rsp), %eax
movl %eax, 0xd0(%rsp)
callq 0x35780
movq %rax, %rdi
callq 0x369d0
movl %eax, 0xd4(%rsp)
jmp 0x35c04
movl 0xd0(%rsp), %eax
movl 0xd4(%rsp), %ecx
cmpl %ecx, %eax
jge 0x3683e
movq 0xd8(%rsp), %rsi
leaq 0x348(%rsp), %rdi
movq %rdi, 0xc0(%rsp)
callq 0x357f0
movq 0xc0(%rsp), %rsi
movl 0x368(%rsp), %edx
leaq 0xe277b(%rip), %rdi     # 0x1183c8
callq 0x369f0
movl %eax, 0xcc(%rsp)
jmp 0x35c5b
leaq 0x348(%rsp), %rdi
callq 0x357d0
movl 0xcc(%rsp), %eax
movl %eax, 0x358(%rsp)
movl 0x358(%rsp), %edi
movl 0x36c(%rsp), %esi
callq 0x36c30
movl %eax, 0xbc(%rsp)
jmp 0x35c92
movl 0xbc(%rsp), %eax
movl %eax, 0x344(%rsp)
movl 0x344(%rsp), %eax
cmpl 0x36c(%rsp), %eax
je 0x3631c
leaq 0x378(%rsp), %rdi
callq 0xb610
testb $0x1, %al
jne 0x36304
cmpl $0x5, 0x36c(%rsp)
jne 0x36036
leaq 0x328(%rsp), %rdi
callq 0x36e40
leaq 0xe26cd(%rip), %rax     # 0x1183b8
movq (%rax), %rax
movq %rax, 0xb0(%rsp)
leaq 0x308(%rsp), %rdi
leaq 0x378(%rsp), %rsi
callq 0xb1a0
jmp 0x35d0d
movq 0xb0(%rsp), %rdi
leaq 0x308(%rsp), %rsi
leaq 0x328(%rsp), %rdx
callq 0xf4c0
jmp 0x35d2c
leaq 0x308(%rsp), %rdi
callq 0xb6e8
leaq 0x328(%rsp), %rax
movq %rax, 0x300(%rsp)
movq 0x300(%rsp), %rdi
callq 0x12210
movq %rax, 0x2f8(%rsp)
movq 0x300(%rsp), %rdi
callq 0x12080
movq %rax, 0x2f0(%rsp)
leaq 0x2f8(%rsp), %rdi
leaq 0x2f0(%rsp), %rsi
callq 0x36e50
testb $0x1, %al
jne 0x35d91
jmp 0x36012
leaq 0x2f8(%rsp), %rdi
callq 0x36e90
movq %rax, %rsi
leaq 0x2e0(%rsp), %rdi
movq %rdi, 0xa0(%rsp)
callq 0xf970
movq 0xa0(%rsp), %rdi
movq 0x398(%rsp), %rax
movq %rax, 0xa8(%rsp)
callq 0xf9f0
movq %rax, %rsi
leaq 0x2b0(%rsp), %rdi
callq 0xfa00
jmp 0x35de5
movq 0xd8(%rsp), %rsi
leaq 0x2a0(%rsp), %rdi
movq %rdi, 0x88(%rsp)
callq 0x357f0
movl 0x374(%rsp), %eax
movl %eax, 0x94(%rsp)
movl 0x370(%rsp), %eax
movl %eax, 0x7c(%rsp)
leaq 0x378(%rsp), %rdi
callq 0xb2a0
movq %rax, %rcx
movl 0x7c(%rsp), %eax
subl %ecx, %eax
movl %eax, 0x98(%rsp)
movl 0x36c(%rsp), %eax
movl %eax, 0x9c(%rsp)
leaq 0x290(%rsp), %rdi
movq %rdi, 0x80(%rsp)
leaq 0x2e0(%rsp), %rsi
callq 0xf970
movq 0x80(%rsp), %rsi
movq 0x88(%rsp), %rdx
movl 0x94(%rsp), %ecx
movl 0x98(%rsp), %r8d
movl 0x9c(%rsp), %r9d
movq %rsp, %rax
movq %rsi, (%rax)
leaq 0x2d0(%rsp), %rdi
leaq 0x2b0(%rsp), %rsi
callq 0x9cd30
jmp 0x35ea7
movq 0xa8(%rsp), %rdi
leaq 0x2d0(%rsp), %rsi
callq 0x36ea0
jmp 0x35ebe
leaq 0x2d0(%rsp), %rdi
callq 0xfc00
leaq 0x290(%rsp), %rdi
callq 0xf9a0
leaq 0x2a0(%rsp), %rdi
callq 0x357d0
leaq 0x2b0(%rsp), %rdi
callq 0xb6e8
leaq 0x2e0(%rsp), %rdi
callq 0xf9a0
leaq 0x2f8(%rsp), %rdi
callq 0x36ed0
jmp 0x35d73
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x360(%rsp)
movl %eax, 0x35c(%rsp)
jmp 0x36853
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x360(%rsp)
movl %eax, 0x35c(%rsp)
leaq 0x348(%rsp), %rdi
callq 0x357d0
jmp 0x36853
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x360(%rsp)
movl %eax, 0x35c(%rsp)
jmp 0x36024
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x360(%rsp)
movl %eax, 0x35c(%rsp)
leaq 0x308(%rsp), %rdi
callq 0xb6e8
jmp 0x36024
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x360(%rsp)
movl %eax, 0x35c(%rsp)
jmp 0x36003
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x360(%rsp)
movl %eax, 0x35c(%rsp)
jmp 0x35fdc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x360(%rsp)
movl %eax, 0x35c(%rsp)
leaq 0x2d0(%rsp), %rdi
callq 0xfc00
leaq 0x290(%rsp), %rdi
callq 0xf9a0
leaq 0x2a0(%rsp), %rdi
callq 0x357d0
leaq 0x2b0(%rsp), %rdi
callq 0xb6e8
leaq 0x2e0(%rsp), %rdi
callq 0xf9a0
jmp 0x36024
leaq 0x328(%rsp), %rdi
callq 0x36ef0
jmp 0x36302
leaq 0x328(%rsp), %rdi
callq 0x36ef0
jmp 0x36853
cmpl $0x6, 0x36c(%rsp)
je 0x3604a
cmpl $0x7, 0x36c(%rsp)
jne 0x3604f
jmp 0x36300
leaq 0x260(%rsp), %rdi
leaq 0x378(%rsp), %rsi
callq 0xb1a0
jmp 0x36066
movq 0xd8(%rsp), %rsi
leaq 0x250(%rsp), %rdi
movq %rdi, 0x68(%rsp)
callq 0x357f0
movl 0x374(%rsp), %eax
movl %eax, 0x70(%rsp)
movl 0x370(%rsp), %eax
movl %eax, 0x5c(%rsp)
leaq 0x378(%rsp), %rdi
callq 0xb2a0
movq %rax, %rcx
movl 0x5c(%rsp), %eax
subl %ecx, %eax
movl %eax, 0x74(%rsp)
movl 0x36c(%rsp), %eax
movl %eax, 0x78(%rsp)
xorl %eax, %eax
movl %eax, %esi
leaq 0x240(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0x36f50
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rdx
movl 0x70(%rsp), %ecx
movl 0x74(%rsp), %r8d
movl 0x78(%rsp), %r9d
movq %rsp, %rax
movq %rsi, (%rax)
leaq 0x280(%rsp), %rdi
leaq 0x260(%rsp), %rsi
callq 0x9cd30
jmp 0x36106
leaq 0x240(%rsp), %rdi
callq 0xf9a0
leaq 0x250(%rsp), %rdi
callq 0x357d0
leaq 0x260(%rsp), %rdi
callq 0xb6e8
cmpl $0xb, 0x36c(%rsp)
jne 0x362c6
leaq 0x9b369(%rip), %rsi     # 0xd14ab
leaq 0x1c8(%rsp), %rdi
leaq 0x378(%rsp), %rdx
callq 0xfab0
jmp 0x36159
leaq 0xa093a(%rip), %rdx     # 0xd6a9a
leaq 0x1e8(%rsp), %rdi
leaq 0x1c8(%rsp), %rsi
callq 0xfa60
jmp 0x36177
leaq 0x1b8(%rsp), %rdi
movq %rdi, 0x50(%rsp)
leaq 0x280(%rsp), %rsi
callq 0x1bc90
movq 0x50(%rsp), %rcx
leaq 0x208(%rsp), %rdi
leaq 0x1e8(%rsp), %rsi
xorl %edx, %edx
callq 0x35600
jmp 0x361af
leaq 0x208(%rsp), %rdi
callq 0x356b0
jmp 0x361be
leaq 0x208(%rsp), %rdi
callq 0x1a670
leaq 0x1b8(%rsp), %rdi
callq 0xfc00
leaq 0x1e8(%rsp), %rdi
callq 0xb6e8
leaq 0x1c8(%rsp), %rdi
callq 0xb6e8
jmp 0x362df
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x360(%rsp)
movl %eax, 0x35c(%rsp)
leaq 0x240(%rsp), %rdi
callq 0xf9a0
leaq 0x250(%rsp), %rdi
callq 0x357d0
leaq 0x260(%rsp), %rdi
callq 0xb6e8
jmp 0x36853
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x360(%rsp)
movl %eax, 0x35c(%rsp)
jmp 0x362ee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x360(%rsp)
movl %eax, 0x35c(%rsp)
jmp 0x362b7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x360(%rsp)
movl %eax, 0x35c(%rsp)
jmp 0x3629d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x360(%rsp)
movl %eax, 0x35c(%rsp)
leaq 0x208(%rsp), %rdi
callq 0x1a670
leaq 0x1b8(%rsp), %rdi
callq 0xfc00
leaq 0x1e8(%rsp), %rdi
callq 0xb6e8
leaq 0x1c8(%rsp), %rdi
callq 0xb6e8
jmp 0x362ee
movq 0x398(%rsp), %rdi
leaq 0x280(%rsp), %rsi
callq 0x36f70
jmp 0x362dd
jmp 0x362df
leaq 0x280(%rsp), %rdi
callq 0xfc00
jmp 0x36300
leaq 0x280(%rsp), %rdi
callq 0xfc00
jmp 0x36853
jmp 0x36302
jmp 0x36304
leaq 0x9b714(%rip), %rsi     # 0xd1a1f
leaq 0x378(%rsp), %rdi
callq 0xb4b0
jmp 0x3631a
jmp 0x3631c
cmpl $0x0, 0x344(%rsp)
je 0x367bb
cmpl $0x1, 0x344(%rsp)
je 0x367bb
cmpl $0x4, 0x344(%rsp)
jne 0x3677f
movq 0xd8(%rsp), %rdi
callq 0x36fe0
movq %rax, %rdi
movl 0x368(%rsp), %esi
callq 0x37010
movb %al, 0x4f(%rsp)
jmp 0x36368
movb 0x4f(%rsp), %al
movsbl %al, %eax
cmpl $0x5c, %eax
jne 0x3677f
movq 0xd8(%rsp), %rdi
movl 0x368(%rsp), %eax
incl %eax
movl %eax, 0x368(%rsp)
callq 0x36fe0
movq %rax, %rdi
movl 0x368(%rsp), %esi
callq 0x37010
movb %al, 0x4e(%rsp)
jmp 0x363aa
movb 0x4e(%rsp), %al
movsbl %al, %eax
cmpl $0x6e, %eax
jne 0x363cf
leaq 0x378(%rsp), %rdi
movl $0xa, %esi
callq 0xb260
jmp 0x363ca
jmp 0x3677d
movq 0xd8(%rsp), %rdi
callq 0x36fe0
movq %rax, %rdi
movl 0x368(%rsp), %esi
callq 0x37010
movb %al, 0x4d(%rsp)
jmp 0x363f1
movb 0x4d(%rsp), %al
movsbl %al, %eax
cmpl $0x22, %eax
jne 0x36416
leaq 0x378(%rsp), %rdi
movl $0x22, %esi
callq 0xb260
jmp 0x36411
jmp 0x3677b
movq 0xd8(%rsp), %rdi
callq 0x36fe0
movq %rax, %rdi
movl 0x368(%rsp), %esi
callq 0x37010
movb %al, 0x4c(%rsp)
jmp 0x36438
movb 0x4c(%rsp), %al
movsbl %al, %eax
cmpl $0x74, %eax
jne 0x3645d
leaq 0x378(%rsp), %rdi
movl $0x9, %esi
callq 0xb260
jmp 0x36458
jmp 0x36779
movq 0xd8(%rsp), %rdi
callq 0x36fe0
movq %rax, %rdi
movl 0x368(%rsp), %esi
callq 0x37010
movb %al, 0x4b(%rsp)
jmp 0x3647f
movb 0x4b(%rsp), %al
movsbl %al, %eax
cmpl $0x5c, %eax
jne 0x364a4
leaq 0x378(%rsp), %rdi
movl $0x5c, %esi
callq 0xb260
jmp 0x3649f
jmp 0x36777
movb $0x1, 0xe7(%rsp)
movl $0x38, %edi
callq 0xb1f0
movq %rax, 0x38(%rsp)
leaq 0x138(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0xb4e0
movq 0x40(%rsp), %rsi
leaq 0x9bcf7(%rip), %rdx     # 0xd21d0
leaq 0x158(%rsp), %rdi
callq 0xfa60
jmp 0x364e8
movq 0xd8(%rsp), %rdi
callq 0x36fe0
movq %rax, %rdi
movl 0x368(%rsp), %esi
callq 0x37010
movb %al, 0x37(%rsp)
jmp 0x3650a
movb 0x37(%rsp), %al
movsbl %al, %edx
leaq 0x178(%rsp), %rdi
leaq 0x158(%rsp), %rsi
callq 0x37040
jmp 0x36528
leaq 0xa056b(%rip), %rdx     # 0xd6a9a
leaq 0x198(%rsp), %rdi
leaq 0x178(%rsp), %rsi
callq 0xfa60
jmp 0x36546
movq 0xd8(%rsp), %rdi
callq 0x36fe0
movq %rax, %rdi
movl 0x368(%rsp), %esi
callq 0x37010
movb %al, 0x36(%rsp)
jmp 0x36568
movb 0x36(%rsp), %al
movsbl %al, %edx
leaq 0x108(%rsp), %rdi
leaq 0x378(%rsp), %rsi
callq 0x37090
jmp 0x36586
movq 0xd8(%rsp), %rsi
leaq 0xf8(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x357f0
movl 0x374(%rsp), %eax
movl %eax, 0x28(%rsp)
movl 0x370(%rsp), %eax
movl %eax, 0x14(%rsp)
leaq 0x378(%rsp), %rdi
callq 0xb2a0
movq %rax, %rcx
movl 0x14(%rsp), %eax
subl %ecx, %eax
movl %eax, 0x2c(%rsp)
movl 0x36c(%rsp), %eax
movl %eax, 0x30(%rsp)
xorl %eax, %eax
movl %eax, %esi
leaq 0xe8(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x36f50
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
movl 0x28(%rsp), %ecx
movl 0x2c(%rsp), %r8d
movl 0x30(%rsp), %r9d
movq %rsp, %rax
movq %rsi, (%rax)
leaq 0x128(%rsp), %rdi
leaq 0x108(%rsp), %rsi
callq 0x9cd30
jmp 0x36626
movq 0x38(%rsp), %rdi
leaq 0x198(%rsp), %rsi
xorl %edx, %edx
leaq 0x128(%rsp), %rcx
callq 0x35600
jmp 0x36644
movq 0x38(%rsp), %rdi
movb $0x0, 0xe7(%rsp)
leaq 0xdef70(%rip), %rsi     # 0x1155c8
leaq -0x1bfef(%rip), %rdx    # 0x1a670
callq 0xb640
jmp 0x3686d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x360(%rsp)
movl %eax, 0x35c(%rsp)
jmp 0x3674f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x360(%rsp)
movl %eax, 0x35c(%rsp)
jmp 0x36742
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x360(%rsp)
movl %eax, 0x35c(%rsp)
jmp 0x36735
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x360(%rsp)
movl %eax, 0x35c(%rsp)
jmp 0x36728
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x360(%rsp)
movl %eax, 0x35c(%rsp)
jmp 0x36701
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x360(%rsp)
movl %eax, 0x35c(%rsp)
leaq 0x128(%rsp), %rdi
callq 0xfc00
leaq 0xe8(%rsp), %rdi
callq 0xf9a0
leaq 0xf8(%rsp), %rdi
callq 0x357d0
leaq 0x108(%rsp), %rdi
callq 0xb6e8
leaq 0x198(%rsp), %rdi
callq 0xb6e8
leaq 0x178(%rsp), %rdi
callq 0xb6e8
leaq 0x158(%rsp), %rdi
callq 0xb6e8
leaq 0x138(%rsp), %rdi
callq 0xb6e8
testb $0x1, 0xe7(%rsp)
jne 0x36768
jmp 0x36772
movq 0x38(%rsp), %rdi
callq 0xb2d0
jmp 0x36853
jmp 0x36779
jmp 0x3677b
jmp 0x3677d
jmp 0x367b9
movq 0xd8(%rsp), %rdi
callq 0x36fe0
movq %rax, %rdi
movl 0x368(%rsp), %esi
callq 0x37010
movb %al, 0x13(%rsp)
jmp 0x367a1
movb 0x13(%rsp), %al
movsbl %al, %esi
leaq 0x378(%rsp), %rdi
callq 0xb260
jmp 0x367b7
jmp 0x367b9
jmp 0x367bb
movq 0xd8(%rsp), %rdi
movl 0x344(%rsp), %eax
movl %eax, 0x36c(%rsp)
callq 0x36fe0
movq %rax, %rdi
movl 0x368(%rsp), %esi
callq 0x37010
movb %al, 0x12(%rsp)
jmp 0x367eb
movb 0x12(%rsp), %al
movsbl %al, %eax
cmpl $0xa, %eax
jne 0x36815
movl 0x374(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x374(%rsp)
movl $0x1, 0x370(%rsp)
jmp 0x36826
movl 0x370(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x370(%rsp)
jmp 0x36828
movl 0x368(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x368(%rsp)
jmp 0x35bd8
leaq 0x378(%rsp), %rdi
callq 0xb6e8
addq $0x3a8, %rsp            # imm = 0x3A8
retq
leaq 0x378(%rsp), %rdi
callq 0xb6e8
movq 0x360(%rsp), %rdi
callq 0xb680
nopl (%rax)