// File: menhits[P]phplus/src/Parser.cpp
// Function: parseTokenList(std::vector<std::shared_ptr<TokenData>, std::allocator<std::shared_ptr<TokenData>>> const&, int, int, std::vector<std::unique_ptr<AstNodeBase, std::default_delete<AstNodeBase>>, std::allocator<std::unique_ptr<AstNodeBase, std::default_delete<AstNodeBase>>>>&)
void parseTokenList(const vector<Token>& tokens, int left, int right, vector<AstNode>& nodes)
{
	int start=left;
	
	for (int i=left; i<=right; i++)
	{
		if (tokens[i]->getOp()==ops->import)
		{
			if (i==right || tokens[i+1]->getType()!=TokenData::STRING_LITERAL)
			{
				throw PhplusError("'"+ops->import->getText()+"' must be followed by a string literal", SOURCE_ERROR, tokens[i]);
			}
			
			string path=tokens[i+1]->getText();
			
			//this nonesens is required because my lexer is shit and includes the first quote but not the last one
			//instead of hardcoding that in, I figured I'd make it flexable so I don't break everthing when I fix the lexer
			
			while (path.size()>0 && path[0]=='"')
				path=path.substr(1, string::npos);
			
			while (path.size()>0 && path[path.size()-1]=='"')
				path=path.substr(0, path.size()-1);
			
			path=tokens[i]->getFile()->getDirPath()+"/"+path;
			
			try
			{
				importFile(nodes, path);
			}
			catch (PhplusError err)
			{
				err.log();
			}
			
			
			i+=2;
			start=i;
		}
		else
		{
			if (ops->isOpenBrac(tokens[i]->getOp()))
			{
				i=skipBrace(tokens, i);
			}
			
			bool tokenTakesRightInput=(tokens[i]->getOp() && tokens[i]->getOp()->takesRightInput());
			int next=i+1;
			bool nextTokenTakesLeftInput=(next<=right && tokens[next]->getOp() && tokens[next]->getOp()->takesLeftInput());
			
			if (i==right || (!tokenTakesRightInput && !nextTokenTakesLeftInput))
			{
				try
				{
					AstNode node=parseExpression(tokens, start, i);
					nodes.push_back(move(node));
				}
				catch (PhplusError err)
				{
					err.log();
				}
				
				start=next;
			}
		}
	}
}

// Assembly:
subq $0x328, %rsp            # imm = 0x328
movq %rdi, 0x320(%rsp)
movl %esi, 0x31c(%rsp)
movl %edx, 0x318(%rsp)
movq %rcx, 0x310(%rsp)
movl 0x31c(%rsp), %eax
movl %eax, 0x30c(%rsp)
movl 0x31c(%rsp), %eax
movl %eax, 0x308(%rsp)
movl 0x308(%rsp), %eax
cmpl 0x318(%rsp), %eax
jg 0x435ee
movq 0x320(%rsp), %rdi
movslq 0x308(%rsp), %rsi
callq 0x48650
movq %rax, %rdi
callq 0x1bb70
movq %rax, %rsi
leaq 0x2f8(%rsp), %rdi
callq 0x1bc10
leaq 0xd58ff(%rip), %rax     # 0x1183b8
movq (%rax), %rsi
addq $0x180, %rsi            # imm = 0x180
leaq 0x2f8(%rsp), %rdi
callq 0xfd20
movb %al, 0x8f(%rsp)
leaq 0x2f8(%rsp), %rdi
callq 0xf9a0
movb 0x8f(%rsp), %al
testb $0x1, %al
jne 0x42af4
jmp 0x43105
movl 0x308(%rsp), %eax
cmpl 0x318(%rsp), %eax
je 0x42b37
movq 0x320(%rsp), %rdi
movl 0x308(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x48650
movq %rax, %rdi
callq 0x1bb70
movq %rax, %rdi
callq 0x1bee0
cmpl $0x4, %eax
je 0x42ccd
movb $0x1, 0x277(%rsp)
movl $0x38, %edi
callq 0xb1f0
movq %rax, 0x80(%rsp)
leaq 0xd5860(%rip), %rax     # 0x1183b8
movq (%rax), %rdi
addq $0x180, %rdi            # imm = 0x180
callq 0xf9f0
movq %rax, %rsi
leaq 0x298(%rsp), %rdi
callq 0xfa00
jmp 0x42b79
leaq 0x93f1a(%rip), %rsi     # 0xd6a9a
leaq 0x2b8(%rsp), %rdi
leaq 0x298(%rsp), %rdx
callq 0x1bcf0
jmp 0x42b97
leaq 0x8fa80(%rip), %rdx     # 0xd261e
leaq 0x2d8(%rsp), %rdi
leaq 0x2b8(%rsp), %rsi
callq 0xfa60
jmp 0x42bb5
movq 0x320(%rsp), %rdi
movslq 0x308(%rsp), %rsi
callq 0x48650
movq %rax, %rsi
leaq 0x278(%rsp), %rdi
movq %rdi, 0x78(%rsp)
callq 0x1bc90
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rcx
leaq 0x2d8(%rsp), %rsi
xorl %edx, %edx
callq 0x35600
jmp 0x42bfd
movq 0x80(%rsp), %rdi
movb $0x0, 0x277(%rsp)
leaq 0xd29b4(%rip), %rsi     # 0x1155c8
leaq -0x285ab(%rip), %rdx    # 0x1a670
callq 0xb640
jmp 0x4360b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x290(%rsp)
movl %eax, 0x28c(%rsp)
jmp 0x42caf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x290(%rsp)
movl %eax, 0x28c(%rsp)
jmp 0x42ca2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x290(%rsp)
movl %eax, 0x28c(%rsp)
jmp 0x42c95
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x290(%rsp)
movl %eax, 0x28c(%rsp)
leaq 0x278(%rsp), %rdi
callq 0xfc00
leaq 0x2d8(%rsp), %rdi
callq 0xb6e8
leaq 0x2b8(%rsp), %rdi
callq 0xb6e8
leaq 0x298(%rsp), %rdi
callq 0xb6e8
testb $0x1, 0x277(%rsp)
jne 0x42cbb
jmp 0x42cc8
movq 0x80(%rsp), %rdi
callq 0xb2d0
jmp 0x435f6
movq 0x320(%rsp), %rdi
movl 0x308(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x48650
movq %rax, %rdi
callq 0x1bb70
movq %rax, %rsi
leaq 0x250(%rsp), %rdi
callq 0x1bb80
leaq 0x250(%rsp), %rdi
callq 0xb2a0
movq %rax, %rcx
xorl %eax, %eax
cmpq $0x0, %rcx
movb %al, 0x77(%rsp)
jbe 0x42d45
xorl %eax, %eax
movl %eax, %esi
leaq 0x250(%rsp), %rdi
callq 0xb6d0
movq %rax, 0x68(%rsp)
jmp 0x42d33
movq 0x68(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x22, %eax
sete %al
movb %al, 0x77(%rsp)
movb 0x77(%rsp), %al
testb $0x1, %al
jne 0x42d4f
jmp 0x42db2
leaq 0x230(%rsp), %rdi
leaq 0x250(%rsp), %rsi
movl $0x1, %edx
movq $-0x1, %rcx
callq 0xb3a0
jmp 0x42d72
leaq 0x250(%rsp), %rdi
leaq 0x230(%rsp), %rsi
callq 0xb450
leaq 0x230(%rsp), %rdi
callq 0xb6e8
jmp 0x42cff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x290(%rsp)
movl %eax, 0x28c(%rsp)
jmp 0x430f3
jmp 0x42db4
leaq 0x250(%rsp), %rdi
callq 0xb2a0
movq %rax, %rcx
xorl %eax, %eax
cmpq $0x0, %rcx
movb %al, 0x67(%rsp)
jbe 0x42e0b
leaq 0x250(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0xb2a0
movq 0x50(%rsp), %rdi
movq %rax, %rsi
decq %rsi
callq 0xb6d0
movq %rax, 0x58(%rsp)
jmp 0x42df9
movq 0x58(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x22, %eax
sete %al
movb %al, 0x67(%rsp)
movb 0x67(%rsp), %al
testb $0x1, %al
jne 0x42e15
jmp 0x42e6c
leaq 0x250(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0xb2a0
movq 0x48(%rsp), %rsi
movq %rax, %rcx
decq %rcx
xorl %eax, %eax
movl %eax, %edx
leaq 0x210(%rsp), %rdi
callq 0xb3a0
jmp 0x42e45
leaq 0x250(%rsp), %rdi
leaq 0x210(%rsp), %rsi
callq 0xb450
leaq 0x210(%rsp), %rdi
callq 0xb6e8
jmp 0x42db4
movq 0x320(%rsp), %rdi
movslq 0x308(%rsp), %rsi
callq 0x48650
movq %rax, %rdi
callq 0x1bb70
movq %rax, %rsi
leaq 0x1a0(%rsp), %rdi
callq 0x35750
jmp 0x42e9b
leaq 0x1a0(%rsp), %rdi
callq 0x35780
movq %rax, %rsi
leaq 0x1b0(%rsp), %rdi
callq 0x9b920
jmp 0x42eba
leaq 0x931dd(%rip), %rdx     # 0xd609e
leaq 0x1d0(%rsp), %rdi
leaq 0x1b0(%rsp), %rsi
callq 0xfa60
jmp 0x42ed8
leaq 0x1f0(%rsp), %rdi
leaq 0x1d0(%rsp), %rsi
leaq 0x250(%rsp), %rdx
callq 0x2e070
jmp 0x42ef7
leaq 0x250(%rsp), %rdi
movq %rdi, 0x38(%rsp)
leaq 0x1f0(%rsp), %rsi
movq %rsi, 0x30(%rsp)
callq 0xb450
movq 0x30(%rsp), %rdi
callq 0xb6e8
leaq 0x1d0(%rsp), %rdi
callq 0xb6e8
leaq 0x1b0(%rsp), %rdi
callq 0xb6e8
leaq 0x1a0(%rsp), %rdi
callq 0x357d0
movq 0x38(%rsp), %rsi
movq 0x310(%rsp), %rax
movq %rax, 0x40(%rsp)
leaq 0x180(%rsp), %rdi
callq 0xb1a0
jmp 0x42f68
movq 0x40(%rsp), %rdi
leaq 0x180(%rsp), %rsi
callq 0x48080
jmp 0x42f7c
leaq 0x180(%rsp), %rdi
callq 0xb6e8
jmp 0x43098
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x290(%rsp)
movl %eax, 0x28c(%rsp)
jmp 0x42fe8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x290(%rsp)
movl %eax, 0x28c(%rsp)
jmp 0x42fdb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x290(%rsp)
movl %eax, 0x28c(%rsp)
leaq 0x1d0(%rsp), %rdi
callq 0xb6e8
leaq 0x1b0(%rsp), %rdi
callq 0xb6e8
leaq 0x1a0(%rsp), %rdi
callq 0x357d0
jmp 0x430f3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x290(%rsp)
movl %eax, 0x28c(%rsp)
jmp 0x43031
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x290(%rsp)
movl %eax, 0x28c(%rsp)
leaq 0x180(%rsp), %rdi
callq 0xb6e8
movl 0x28c(%rsp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x430f3
movq 0x290(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0xb460
movq %rax, %rsi
leaq 0x148(%rsp), %rdi
callq 0x1ad40
jmp 0x43069
movq 0x28(%rsp), %rdi
callq 0xb180
leaq 0x148(%rsp), %rdi
callq 0x356b0
jmp 0x43082
leaq 0x148(%rsp), %rdi
callq 0x1a670
callq 0xb5f0
jmp 0x43096
jmp 0x43098
movl 0x308(%rsp), %eax
addl $0x2, %eax
movl %eax, 0x308(%rsp)
movl 0x308(%rsp), %eax
movl %eax, 0x30c(%rsp)
leaq 0x250(%rsp), %rdi
callq 0xb6e8
jmp 0x435d6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x290(%rsp)
movl %eax, 0x28c(%rsp)
leaq 0x148(%rsp), %rdi
callq 0x1a670
callq 0xb5f0
jmp 0x430f1
jmp 0x430f3
leaq 0x250(%rsp), %rdi
callq 0xb6e8
jmp 0x435f6
leaq 0xd52ac(%rip), %rax     # 0x1183b8
movq (%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x320(%rsp), %rdi
movslq 0x308(%rsp), %rsi
callq 0x48650
movq %rax, %rdi
callq 0x1bb70
movq %rax, %rsi
leaq 0x138(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x1bc10
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0xf780
movb %al, 0x27(%rsp)
jmp 0x4315b
leaq 0x138(%rsp), %rdi
callq 0xf9a0
movb 0x27(%rsp), %al
testb $0x1, %al
jne 0x43172
jmp 0x431b5
movq 0x320(%rsp), %rdi
movl 0x308(%rsp), %esi
callq 0x43610
movl %eax, 0x308(%rsp)
jmp 0x431b5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x290(%rsp)
movl %eax, 0x28c(%rsp)
leaq 0x138(%rsp), %rdi
callq 0xf9a0
jmp 0x435f6
movq 0x320(%rsp), %rdi
movslq 0x308(%rsp), %rsi
callq 0x48650
movq %rax, %rdi
callq 0x1bb70
movq %rax, %rsi
leaq 0x120(%rsp), %rdi
callq 0x1bc10
leaq 0x120(%rsp), %rdi
callq 0x1bef0
movb %al, %cl
movb $0x0, 0x10f(%rsp)
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0xf(%rsp)
jne 0x43206
jmp 0x43262
movq 0x320(%rsp), %rdi
movslq 0x308(%rsp), %rsi
callq 0x48650
movq %rax, %rdi
callq 0x1bb70
movq %rax, %rsi
leaq 0x110(%rsp), %rdi
callq 0x1bc10
jmp 0x43235
movb $0x1, 0x10f(%rsp)
leaq 0x110(%rsp), %rdi
callq 0xf9f0
movq %rax, %rdi
callq 0x48840
movb %al, 0xe(%rsp)
jmp 0x43258
movb 0xe(%rsp), %al
movb %al, 0xf(%rsp)
jmp 0x43262
movb 0xf(%rsp), %al
movb %al, 0xd(%rsp)
testb $0x1, 0x10f(%rsp)
jne 0x43276
jmp 0x43283
leaq 0x110(%rsp), %rdi
callq 0xf9a0
leaq 0x120(%rsp), %rdi
callq 0xf9a0
movb 0xd(%rsp), %al
andb $0x1, %al
movb %al, 0x137(%rsp)
movl 0x308(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x108(%rsp)
movl 0x108(%rsp), %ecx
movl 0x318(%rsp), %edx
movb $0x0, 0xef(%rsp)
movb $0x0, 0xd7(%rsp)
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, 0xc(%rsp)
jg 0x43387
movq 0x320(%rsp), %rdi
movslq 0x108(%rsp), %rsi
callq 0x48650
movq %rax, %rdi
callq 0x1bb70
movq %rax, %rsi
leaq 0xf0(%rsp), %rdi
callq 0x1bc10
movb $0x1, 0xef(%rsp)
leaq 0xf0(%rsp), %rdi
callq 0x1bef0
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0xc(%rsp)
jne 0x4332b
jmp 0x43387
movq 0x320(%rsp), %rdi
movslq 0x108(%rsp), %rsi
callq 0x48650
movq %rax, %rdi
callq 0x1bb70
movq %rax, %rsi
leaq 0xd8(%rsp), %rdi
callq 0x1bc10
jmp 0x4335a
movb $0x1, 0xd7(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0xf9f0
movq %rax, %rdi
callq 0x48800
movb %al, 0xb(%rsp)
jmp 0x4337d
movb 0xb(%rsp), %al
movb %al, 0xc(%rsp)
jmp 0x43387
movb 0xc(%rsp), %al
movb %al, 0xa(%rsp)
testb $0x1, 0xd7(%rsp)
jne 0x4339b
jmp 0x433a8
leaq 0xd8(%rsp), %rdi
callq 0xf9a0
testb $0x1, 0xef(%rsp)
jne 0x433b4
jmp 0x433c1
leaq 0xf0(%rsp), %rdi
callq 0xf9a0
movb 0xa(%rsp), %al
andb $0x1, %al
movb %al, 0x107(%rsp)
movl 0x308(%rsp), %eax
cmpl 0x318(%rsp), %eax
je 0x433fa
testb $0x1, 0x137(%rsp)
jne 0x435d4
testb $0x1, 0x107(%rsp)
jne 0x435d4
movq 0x320(%rsp), %rsi
movl 0x30c(%rsp), %edx
movl 0x308(%rsp), %ecx
leaq 0xc8(%rsp), %rdi
callq 0x443c0
jmp 0x4341f
movq 0x310(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0x1eac0
jmp 0x43436
leaq 0xc8(%rsp), %rdi
callq 0x1b3f0
jmp 0x4359a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x290(%rsp)
movl %eax, 0x28c(%rsp)
jmp 0x4348d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x290(%rsp)
movl %eax, 0x28c(%rsp)
testb $0x1, 0x10f(%rsp)
jne 0x4347e
jmp 0x4348b
leaq 0x110(%rsp), %rdi
callq 0xf9a0
jmp 0x4348d
leaq 0x120(%rsp), %rdi
callq 0xf9a0
jmp 0x435f6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x290(%rsp)
movl %eax, 0x28c(%rsp)
jmp 0x434e4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x290(%rsp)
movl %eax, 0x28c(%rsp)
testb $0x1, 0xd7(%rsp)
jne 0x434d5
jmp 0x434e2
leaq 0xd8(%rsp), %rdi
callq 0xf9a0
jmp 0x434e4
testb $0x1, 0xef(%rsp)
jne 0x434f0
jmp 0x434fd
leaq 0xf0(%rsp), %rdi
callq 0xf9a0
jmp 0x435f6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x290(%rsp)
movl %eax, 0x28c(%rsp)
jmp 0x43539
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x290(%rsp)
movl %eax, 0x28c(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0x1b3f0
movl 0x28c(%rsp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x435f6
movq 0x290(%rsp), %rdi
movq %rdi, (%rsp)
callq 0xb460
movq %rax, %rsi
leaq 0x90(%rsp), %rdi
callq 0x1ad40
jmp 0x43570
movq (%rsp), %rdi
callq 0xb180
leaq 0x90(%rsp), %rdi
callq 0x356b0
jmp 0x43588
leaq 0x90(%rsp), %rdi
callq 0x1a670
callq 0xb5f0
movl 0x108(%rsp), %eax
movl %eax, 0x30c(%rsp)
jmp 0x435d4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x290(%rsp)
movl %eax, 0x28c(%rsp)
leaq 0x90(%rsp), %rdi
callq 0x1a670
callq 0xb5f0
jmp 0x435d2
jmp 0x435f6
jmp 0x435d6
jmp 0x435d8
movl 0x308(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x308(%rsp)
jmp 0x42a71
addq $0x328, %rsp            # imm = 0x328
retq
movq 0x290(%rsp), %rdi
callq 0xb680
movq %rax, %rdi
callq 0xffe0
nopl (%rax,%rax)