// File: Davidc2525[P]Leaf/parser/Scanner.cpp
// Function: Scanner::Init()
void Scanner::Init() {
	EOL    = '\n';
	eofSym = 0;
	maxT = 50;
	noSym = 50;
	int i;
	for (i = 49; i <= 57; ++i) start.set(i, 28);
	for (i = 65; i <= 90; ++i) start.set(i, 2);
	for (i = 95; i <= 95; ++i) start.set(i, 2);
	for (i = 97; i <= 122; ++i) start.set(i, 2);
	for (i = 145; i <= 145; ++i) start.set(i, 2);
	for (i = 177; i <= 177; ++i) start.set(i, 2);
	for (i = 195; i <= 195; ++i) start.set(i, 2);
	start.set(42, 1);
	start.set(38, 56);
	start.set(39, 3);
	start.set(34, 6);
	start.set(46, 57);
	start.set(48, 29);
	start.set(123, 32);
	start.set(125, 33);
	start.set(59, 34);
	start.set(61, 58);
	start.set(40, 35);
	start.set(41, 36);
	start.set(58, 37);
	start.set(44, 38);
	start.set(91, 39);
	start.set(93, 40);
	start.set(60, 59);
	start.set(62, 60);
	start.set(126, 43);
	start.set(124, 61);
	start.set(94, 44);
	start.set(33, 48);
	start.set(43, 52);
	start.set(45, 53);
	start.set(47, 54);
	start.set(37, 55);
		start.set(Buffer::EoF, -1);
	keywords.set(L"class", 13);
	keywords.set(L"print", 14);
	keywords.set(L"sizeof", 17);
	keywords.set(L"ret", 18);
	keywords.set(L"if", 19);
	keywords.set(L"else", 20);
	keywords.set(L"throw", 21);
	keywords.set(L"try", 22);
	keywords.set(L"catch", 23);
	keywords.set(L"extern", 28);
	keywords.set(L"fun", 29);
	keywords.set(L"true", 47);
	keywords.set(L"false", 48);


	tvalLength = 128;
	tval = new wchar_t[tvalLength]; // text of current token

	// COCO_HEAP_BLOCK_SIZE byte heap + pointer to next heap block
	heap = malloc(COCO_HEAP_BLOCK_SIZE + sizeof(void*));
	firstHeap = heap;
	heapEnd = (void**) (((char*) heap) + COCO_HEAP_BLOCK_SIZE);
	*heapEnd = 0;
	heapTop = heap;
	if (sizeof(Token) > COCO_HEAP_BLOCK_SIZE) {
		printf("--- Too small COCO_HEAP_BLOCK_SIZE\n");
		exit(1);
	}

	pos = -1; line = 1; col = 0; charPos = -1;
	oldEols = 0;
	NextCh();
	if (ch == 0xEF) { // check optional byte order mark for UTF-8
		NextCh(); int ch1 = ch;
		NextCh(); int ch2 = ch;
		if (ch1 != 0xBB || ch2 != 0xBF) {
			printf("Illegal byte order mark at start of file");
			exit(1);
		}
		Buffer *oldBuf = buffer;
		buffer = new UTF8Buffer(buffer); col = 0; charPos = -1;
		delete oldBuf; oldBuf = NULL;
		NextCh();
	}


	pt = tokens = CreateToken(); // first token is a dummy
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
movb $0xa, 0x20(%rax)
movl $0x0, 0x24(%rax)
movl $0x32, 0x2c(%rax)
movl $0x32, 0x28(%rax)
movl $0x31, -0xc(%rbp)
cmpl $0x39, -0xc(%rbp)
jg 0xfeda
movq -0x38(%rbp), %rdi
addq $0x38, %rdi
movl -0xc(%rbp), %esi
movl $0x1c, %edx
callq 0x12790
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0xfeb4
movl $0x41, -0xc(%rbp)
cmpl $0x5a, -0xc(%rbp)
jg 0xff07
movq -0x38(%rbp), %rdi
addq $0x38, %rdi
movl -0xc(%rbp), %esi
movl $0x2, %edx
callq 0x12790
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0xfee1
movl $0x5f, -0xc(%rbp)
cmpl $0x5f, -0xc(%rbp)
jg 0xff34
movq -0x38(%rbp), %rdi
addq $0x38, %rdi
movl -0xc(%rbp), %esi
movl $0x2, %edx
callq 0x12790
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0xff0e
movl $0x61, -0xc(%rbp)
cmpl $0x7a, -0xc(%rbp)
jg 0xff61
movq -0x38(%rbp), %rdi
addq $0x38, %rdi
movl -0xc(%rbp), %esi
movl $0x2, %edx
callq 0x12790
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0xff3b
movl $0x91, -0xc(%rbp)
cmpl $0x91, -0xc(%rbp)
jg 0xff91
movq -0x38(%rbp), %rdi
addq $0x38, %rdi
movl -0xc(%rbp), %esi
movl $0x2, %edx
callq 0x12790
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0xff68
movl $0xb1, -0xc(%rbp)
cmpl $0xb1, -0xc(%rbp)
jg 0xffc1
movq -0x38(%rbp), %rdi
addq $0x38, %rdi
movl -0xc(%rbp), %esi
movl $0x2, %edx
callq 0x12790
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0xff98
movl $0xc3, -0xc(%rbp)
cmpl $0xc3, -0xc(%rbp)
jg 0xfff1
movq -0x38(%rbp), %rdi
addq $0x38, %rdi
movl -0xc(%rbp), %esi
movl $0x2, %edx
callq 0x12790
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0xffc8
movq -0x38(%rbp), %rdi
addq $0x38, %rdi
movl $0x2a, %esi
movl $0x1, %edx
callq 0x12790
movq -0x38(%rbp), %rdi
addq $0x38, %rdi
movl $0x26, %esi
movl $0x38, %edx
callq 0x12790
movq -0x38(%rbp), %rdi
addq $0x38, %rdi
movl $0x27, %esi
movl $0x3, %edx
callq 0x12790
movq -0x38(%rbp), %rdi
addq $0x38, %rdi
movl $0x22, %esi
movl $0x6, %edx
callq 0x12790
movq -0x38(%rbp), %rdi
addq $0x38, %rdi
movl $0x2e, %esi
movl $0x39, %edx
callq 0x12790
movq -0x38(%rbp), %rdi
addq $0x38, %rdi
movl $0x30, %esi
movl $0x1d, %edx
callq 0x12790
movq -0x38(%rbp), %rdi
addq $0x38, %rdi
movl $0x7b, %esi
movl $0x20, %edx
callq 0x12790
movq -0x38(%rbp), %rdi
addq $0x38, %rdi
movl $0x7d, %esi
movl $0x21, %edx
callq 0x12790
movq -0x38(%rbp), %rdi
addq $0x38, %rdi
movl $0x3b, %esi
movl $0x22, %edx
callq 0x12790
movq -0x38(%rbp), %rdi
addq $0x38, %rdi
movl $0x3d, %esi
movl $0x3a, %edx
callq 0x12790
movq -0x38(%rbp), %rdi
addq $0x38, %rdi
movl $0x28, %esi
movl $0x23, %edx
callq 0x12790
movq -0x38(%rbp), %rdi
addq $0x38, %rdi
movl $0x29, %esi
movl $0x24, %edx
callq 0x12790
movq -0x38(%rbp), %rdi
addq $0x38, %rdi
movl $0x3a, %esi
movl $0x25, %edx
callq 0x12790
movq -0x38(%rbp), %rdi
addq $0x38, %rdi
movl $0x2c, %esi
movl $0x26, %edx
callq 0x12790
movq -0x38(%rbp), %rdi
addq $0x38, %rdi
movl $0x5b, %esi
movl $0x27, %edx
callq 0x12790
movq -0x38(%rbp), %rdi
addq $0x38, %rdi
movl $0x5d, %esi
movl $0x28, %edx
callq 0x12790
movq -0x38(%rbp), %rdi
addq $0x38, %rdi
movl $0x3c, %esi
movl $0x3b, %edx
callq 0x12790
movq -0x38(%rbp), %rdi
addq $0x38, %rdi
movl $0x3e, %esi
movl $0x3c, %edx
callq 0x12790
movq -0x38(%rbp), %rdi
addq $0x38, %rdi
movl $0x7e, %esi
movl $0x2b, %edx
callq 0x12790
movq -0x38(%rbp), %rdi
addq $0x38, %rdi
movl $0x7c, %esi
movl $0x3d, %edx
callq 0x12790
movq -0x38(%rbp), %rdi
addq $0x38, %rdi
movl $0x5e, %esi
movl $0x2c, %edx
callq 0x12790
movq -0x38(%rbp), %rdi
addq $0x38, %rdi
movl $0x21, %esi
movl $0x30, %edx
callq 0x12790
movq -0x38(%rbp), %rdi
addq $0x38, %rdi
movl $0x2b, %esi
movl $0x34, %edx
callq 0x12790
movq -0x38(%rbp), %rdi
addq $0x38, %rdi
movl $0x2d, %esi
movl $0x35, %edx
callq 0x12790
movq -0x38(%rbp), %rdi
addq $0x38, %rdi
movl $0x2f, %esi
movl $0x36, %edx
callq 0x12790
movq -0x38(%rbp), %rdi
addq $0x38, %rdi
movl $0x25, %esi
movl $0x37, %edx
callq 0x12790
movq -0x38(%rbp), %rdi
addq $0x38, %rdi
movl $0x10000, %esi          # imm = 0x10000
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x12790
movq -0x38(%rbp), %rdi
addq $0x48, %rdi
leaq 0x243a3(%rip), %rsi     # 0x34610
movl $0xd, %edx
callq 0x12830
movq -0x38(%rbp), %rdi
addq $0x48, %rdi
leaq 0x243a2(%rip), %rsi     # 0x34628
movl $0xe, %edx
callq 0x12830
movq -0x38(%rbp), %rdi
addq $0x48, %rdi
leaq 0x243a1(%rip), %rsi     # 0x34640
movl $0x11, %edx
callq 0x12830
movq -0x38(%rbp), %rdi
addq $0x48, %rdi
leaq 0x243a4(%rip), %rsi     # 0x3465c
movl $0x12, %edx
callq 0x12830
movq -0x38(%rbp), %rdi
addq $0x48, %rdi
leaq 0x2439b(%rip), %rsi     # 0x3466c
movl $0x13, %edx
callq 0x12830
movq -0x38(%rbp), %rdi
addq $0x48, %rdi
leaq 0x2438e(%rip), %rsi     # 0x34678
movl $0x14, %edx
callq 0x12830
movq -0x38(%rbp), %rdi
addq $0x48, %rdi
leaq 0x24389(%rip), %rsi     # 0x3468c
movl $0x15, %edx
callq 0x12830
movq -0x38(%rbp), %rdi
addq $0x48, %rdi
leaq 0x24388(%rip), %rsi     # 0x346a4
movl $0x16, %edx
callq 0x12830
movq -0x38(%rbp), %rdi
addq $0x48, %rdi
leaq 0x2437f(%rip), %rsi     # 0x346b4
movl $0x17, %edx
callq 0x12830
movq -0x38(%rbp), %rdi
addq $0x48, %rdi
leaq 0x2437e(%rip), %rsi     # 0x346cc
movl $0x1c, %edx
callq 0x12830
movq -0x38(%rbp), %rdi
addq $0x48, %rdi
leaq 0x24381(%rip), %rsi     # 0x346e8
movl $0x1d, %edx
callq 0x12830
movq -0x38(%rbp), %rdi
addq $0x48, %rdi
leaq 0x24378(%rip), %rsi     # 0x346f8
movl $0x2f, %edx
callq 0x12830
movq -0x38(%rbp), %rdi
addq $0x48, %rdi
leaq 0x24373(%rip), %rsi     # 0x3470c
movl $0x30, %edx
callq 0x12830
movq -0x38(%rbp), %rax
movl $0x80, 0x68(%rax)
movslq 0x68(%rax), %rax
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x6040
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x60(%rax)
movl $0x4000008, %edi        # imm = 0x4000008
callq 0x6420
movq -0x38(%rbp), %rdi
movq %rax, 0x8(%rdi)
movq 0x8(%rdi), %rax
movq %rax, (%rdi)
movq 0x8(%rdi), %rax
addq $0x4000000, %rax        # imm = 0x4000000
movq %rax, 0x18(%rdi)
movq 0x18(%rdi), %rax
movq $0x0, (%rax)
movq 0x8(%rdi), %rax
movq %rax, 0x10(%rdi)
movl $0xffffffff, 0x84(%rdi) # imm = 0xFFFFFFFF
movl $0x1, 0x8c(%rdi)
movl $0x0, 0x90(%rdi)
movl $0xffffffff, 0x88(%rdi) # imm = 0xFFFFFFFF
movl $0x0, 0x94(%rdi)
callq 0x10830
movq -0x38(%rbp), %rax
cmpl $0xef, 0x80(%rax)
jne 0x10554
movq -0x38(%rbp), %rdi
callq 0x10830
movq -0x38(%rbp), %rdi
movl 0x80(%rdi), %eax
movl %eax, -0x10(%rbp)
callq 0x10830
movq -0x38(%rbp), %rax
movl 0x80(%rax), %eax
movl %eax, -0x14(%rbp)
cmpl $0xbb, -0x10(%rbp)
jne 0x1049d
cmpl $0xbf, -0x14(%rbp)
je 0x104b5
leaq 0x24129(%rip), %rdi     # 0x345cd
movb $0x0, %al
callq 0x6070
movl $0x1, %edi
callq 0x63d0
movq -0x38(%rbp), %rax
movq 0x98(%rax), %rax
movq %rax, -0x20(%rbp)
movl $0x38, %edi
callq 0x62e0
movq %rax, %rdi
movq -0x38(%rbp), %rax
movq %rdi, %rcx
movq %rcx, -0x40(%rbp)
movq 0x98(%rax), %rsi
callq 0x128e0
jmp 0x104ea
movq -0x38(%rbp), %rax
movq -0x40(%rbp), %rcx
movq %rcx, 0x98(%rax)
movl $0x0, 0x90(%rax)
movl $0xffffffff, 0x88(%rax) # imm = 0xFFFFFFFF
movq -0x20(%rbp), %rax
movq %rax, -0x48(%rbp)
cmpq $0x0, %rax
je 0x10525
movq -0x48(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq -0x38(%rbp), %rdi
movq $0x0, -0x20(%rbp)
callq 0x10830
jmp 0x10554
movq -0x40(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x38, %esi
callq 0x62f0
jmp 0x10572
movq -0x38(%rbp), %rdi
callq 0x10930
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x70(%rax)
movq %rcx, 0x78(%rax)
addq $0x50, %rsp
popq %rbp
retq
movq -0x28(%rbp), %rdi
callq 0x64f0
nopl (%rax,%rax)