// File: rfotino[P]consolite-compiler/src/syntax.cpp
// Function: LiteralToken::parse(AtomToken const&)
bool LiteralToken::parse(const AtomToken& token) {
  _lineNum = token.line();
  if (std::regex_match(token.str(), std::regex("^0[xX][0-9a-fA-F]+$"))) {
    // Matched hex
    _value = 0;
    for (size_t i = 2; i < token.str().size(); i++) {
      char c = token.str().at(i);
      uint8_t hexVal =
        ('0' <= c && c <= '9') ? (c - '0') :
        ('a' <= c && c <= 'f') ? (c - 'a' + 10) : (c - 'A' + 10);
      _value = (_value * 16) + hexVal;
    }
  } else if (std::regex_match(token.str(), std::regex("^0[bB][01]+$"))) {
    // Matched binary
    _value = 0;
    for (size_t i = 2; i < token.str().size(); i++) {
      _value = (_value * 2) + (token.str().at(i) - '0');
    }
  } else if (std::regex_match(token.str(), std::regex("^[0-9]+$"))) {
    // Matched decimal
    _value = 0;
    for (size_t i = 0; i < token.str().size(); i++) {
      char c = token.str().at(i);
      uint8_t decVal = c - '0';
      _value = (_value * 10) + decVal;
    }
  } else {
    return false;
  }
  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x270, %rsp            # imm = 0x270
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x1e8(%rbp)
movq -0x18(%rbp), %rdi
callq 0x32270
movl %eax, %ecx
movq -0x1e8(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x18(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0xd5c0
leaq 0x59491(%rip), %rsi     # 0x6f638
leaq -0x58(%rbp), %rdi
movl $0x10, %edx
callq 0x322e0
jmp 0x161b7
leaq -0x38(%rbp), %rdi
leaq -0x58(%rbp), %rsi
xorl %edx, %edx
callq 0x32290
movb %al, -0x1e9(%rbp)
jmp 0x161ce
leaq -0x58(%rbp), %rdi
callq 0x32380
leaq -0x38(%rbp), %rdi
callq 0x8848
movb -0x1e9(%rbp), %al
testb $0x1, %al
jne 0x161ef
jmp 0x163b5
movq -0x1e8(%rbp), %rax
movw $0x0, 0xc(%rax)
movq $0x2, -0x70(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0x1f8(%rbp)
movq -0x18(%rbp), %rsi
leaq -0x90(%rbp), %rdi
callq 0xd5c0
leaq -0x90(%rbp), %rdi
callq 0x8300
movq %rax, -0x200(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x8848
movq -0x200(%rbp), %rcx
movq -0x1f8(%rbp), %rax
cmpq %rcx, %rax
jae 0x163b0
movq -0x18(%rbp), %rsi
leaq -0xb8(%rbp), %rdi
movq %rdi, -0x210(%rbp)
callq 0xd5c0
movq -0x210(%rbp), %rdi
movq -0x70(%rbp), %rsi
callq 0x87f0
movq %rax, -0x208(%rbp)
jmp 0x16285
movq -0x208(%rbp), %rax
movb (%rax), %al
movb %al, -0x211(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x8848
movb -0x211(%rbp), %al
movb %al, -0x91(%rbp)
movsbl -0x91(%rbp), %ecx
movl $0x30, %eax
cmpl %ecx, %eax
jg 0x162da
movsbl -0x91(%rbp), %eax
cmpl $0x39, %eax
jg 0x162da
movsbl -0x91(%rbp), %eax
subl $0x30, %eax
movl %eax, -0x218(%rbp)
jmp 0x1632a
movsbl -0x91(%rbp), %ecx
movl $0x61, %eax
cmpl %ecx, %eax
jg 0x1630b
movsbl -0x91(%rbp), %eax
cmpl $0x66, %eax
jg 0x1630b
movsbl -0x91(%rbp), %eax
subl $0x61, %eax
addl $0xa, %eax
movl %eax, -0x21c(%rbp)
jmp 0x1631e
movsbl -0x91(%rbp), %eax
subl $0x41, %eax
addl $0xa, %eax
movl %eax, -0x21c(%rbp)
movl -0x21c(%rbp), %eax
movl %eax, -0x218(%rbp)
movq -0x1e8(%rbp), %rax
movl -0x218(%rbp), %ecx
movb %cl, -0xb9(%rbp)
movzwl 0xc(%rax), %ecx
shll $0x4, %ecx
movzbl -0xb9(%rbp), %edx
addl %edx, %ecx
movw %cx, 0xc(%rax)
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
jmp 0x16204
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x16385
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x32380
leaq -0x38(%rbp), %rdi
callq 0x8848
jmp 0x16753
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x8848
jmp 0x16753
jmp 0x16741
movq -0x18(%rbp), %rsi
leaq -0xe0(%rbp), %rdi
callq 0xd5c0
leaq 0x59280(%rip), %rsi     # 0x6f64c
leaq -0x100(%rbp), %rdi
movl $0x10, %edx
callq 0x322e0
jmp 0x163df
leaq -0xe0(%rbp), %rdi
leaq -0x100(%rbp), %rsi
xorl %edx, %edx
callq 0x32290
movb %al, -0x21d(%rbp)
jmp 0x163fc
leaq -0x100(%rbp), %rdi
callq 0x32380
leaq -0xe0(%rbp), %rdi
callq 0x8848
movb -0x21d(%rbp), %al
testb $0x1, %al
jne 0x16423
jmp 0x16571
movq -0x1e8(%rbp), %rax
movw $0x0, 0xc(%rax)
movq $0x2, -0x108(%rbp)
movq -0x108(%rbp), %rax
movq %rax, -0x228(%rbp)
movq -0x18(%rbp), %rsi
leaq -0x128(%rbp), %rdi
callq 0xd5c0
leaq -0x128(%rbp), %rdi
callq 0x8300
movq %rax, -0x230(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x8848
movq -0x230(%rbp), %rcx
movq -0x228(%rbp), %rax
cmpq %rcx, %rax
jae 0x1656c
movq -0x1e8(%rbp), %rax
movzwl 0xc(%rax), %eax
addl %eax, %eax
movl %eax, -0x244(%rbp)
movq -0x18(%rbp), %rsi
leaq -0x148(%rbp), %rdi
movq %rdi, -0x240(%rbp)
callq 0xd5c0
movq -0x240(%rbp), %rdi
movq -0x108(%rbp), %rsi
callq 0x87f0
movq %rax, -0x238(%rbp)
jmp 0x164d5
movq -0x1e8(%rbp), %rax
movl -0x244(%rbp), %ecx
movq -0x238(%rbp), %rdx
movsbl (%rdx), %edx
subl $0x30, %edx
addl %edx, %ecx
movw %cx, 0xc(%rax)
leaq -0x148(%rbp), %rdi
callq 0x8848
movq -0x108(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x108(%rbp)
jmp 0x1643b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x1653e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x32380
leaq -0xe0(%rbp), %rdi
callq 0x8848
jmp 0x16753
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x8848
jmp 0x16753
jmp 0x1673f
movq -0x18(%rbp), %rsi
leaq -0x168(%rbp), %rdi
callq 0xd5c0
leaq 0x590d1(%rip), %rsi     # 0x6f659
leaq -0x188(%rbp), %rdi
movl $0x10, %edx
callq 0x322e0
jmp 0x1659b
leaq -0x168(%rbp), %rdi
leaq -0x188(%rbp), %rsi
xorl %edx, %edx
callq 0x32290
movb %al, -0x245(%rbp)
jmp 0x165b8
leaq -0x188(%rbp), %rdi
callq 0x32380
leaq -0x168(%rbp), %rdi
callq 0x8848
movb -0x245(%rbp), %al
testb $0x1, %al
jne 0x165df
jmp 0x16737
movq -0x1e8(%rbp), %rax
movw $0x0, 0xc(%rax)
movq $0x0, -0x190(%rbp)
movq -0x190(%rbp), %rax
movq %rax, -0x250(%rbp)
movq -0x18(%rbp), %rsi
leaq -0x1b0(%rbp), %rdi
callq 0xd5c0
leaq -0x1b0(%rbp), %rdi
callq 0x8300
movq %rax, -0x258(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x8848
movq -0x258(%rbp), %rcx
movq -0x250(%rbp), %rax
cmpq %rcx, %rax
jae 0x16735
movq -0x18(%rbp), %rsi
leaq -0x1d8(%rbp), %rdi
movq %rdi, -0x268(%rbp)
callq 0xd5c0
movq -0x268(%rbp), %rdi
movq -0x190(%rbp), %rsi
callq 0x87f0
movq %rax, -0x260(%rbp)
jmp 0x1667e
movq -0x260(%rbp), %rax
movb (%rax), %al
movb %al, -0x269(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0x8848
movb -0x269(%rbp), %cl
movq -0x1e8(%rbp), %rax
movb %cl, -0x1b1(%rbp)
movsbl -0x1b1(%rbp), %ecx
subl $0x30, %ecx
movb %cl, -0x1d9(%rbp)
movzwl 0xc(%rax), %ecx
imull $0xa, %ecx, %ecx
movzbl -0x1d9(%rbp), %edx
addl %edx, %ecx
movw %cx, 0xc(%rax)
movq -0x190(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x190(%rbp)
jmp 0x165f7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x1670d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x188(%rbp), %rdi
callq 0x32380
leaq -0x168(%rbp), %rdi
callq 0x8848
jmp 0x16753
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0x8848
jmp 0x16753
jmp 0x1673d
movb $0x0, -0x1(%rbp)
jmp 0x16745
jmp 0x1673f
jmp 0x16741
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x270, %rsp            # imm = 0x270
popq %rbp
retq
movq -0x60(%rbp), %rdi
callq 0x8750
nopl (%rax)