// File: /workspace/github_cpp_makefile_star2_O3/WayfireWM[P]wf-utils/wayfire/lexer/symbol.cpp
// Function: wf::symbol_t::symbol_t(std::variant<int, char, bool, float, double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>> const&)
symbol_t::symbol_t(const variant_t &v) : type(type_t::LITERAL), value(v)
{
    // String literals can also be keywords, comments or identifiers. Check for this.
    if (is_string(value))
    {
        auto literal_value = get_string(value);

        if ((literal_value.front() == '\"') && (literal_value.back() == '\"'))
        {
            value = literal_value.substr(1, literal_value.size() - 2); // Strip quotes here.
        }
        else if (contains(SIGNALS, literal_value))
        {
            type = type_t::SIGNAL;
        }
        else if (contains(KEYWORDS, literal_value))
        {
            type = type_t::KEYWORD;
        }
        else if (contains(STRUCTURES, literal_value))
        {
            type = type_t::STRUCTURAL;
        }
        else if (contains(OPERATORS, literal_value))
        {
            type = type_t::OPERATOR;
        }
        else
        {
            bool first = true;
            for (const auto &c : literal_value)
            {
                auto digit = std::isdigit(c);
                auto letter = std::isalpha(c);
                auto underscore = (c == '_');

                if (first)
                {
                    first = false;
                    if (digit)
                    {
                        std::string error = "Symbol parser error. Identifier should start with _ or letter. text:";
                        error.append(literal_value);
                        throw std::runtime_error(error);
                    }
                }

                if (!(digit | letter | underscore))
                {
                    std::string error = "Symbol parser error. Identifier contains invalid character. text:";
                    error.append(literal_value);
                    throw std::runtime_error(error);
                }
            }
            type = type_t::IDENTIFIER;
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
leaq 0x8(%rdi), %rbx
movq %rdi, %r14
movl $0x2, (%rdi)
movq %rbx, %rdi
callq 0x62aa
movq %rbx, %rdi
callq 0xb344
testb %al, %al
je 0x8a50
movq %rsp, %rdi
movq %rbx, %rsi
callq 0xb34c
movq (%rsp), %rax
cmpb $0x22, (%rax)
jne 0x8960
movq 0x8(%rsp), %rcx
cmpb $0x22, -0x1(%rax,%rcx)
jne 0x8960
addq $-0x2, %rcx
leaq 0x20(%rsp), %rdi
movl $0x1, %edx
movq %rsp, %rsi
callq 0x5250
leaq 0x20(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x8b94
movq (%r14), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x8a35
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x5230
jmp 0x8a35
leaq 0xa991(%rip), %rdi      # 0x132f8
movq %rsp, %rsi
callq 0x79f7
testb %al, %al
je 0x897f
movl $0x6, (%r14)
jmp 0x8a35
leaq 0xa9a2(%rip), %rdi      # 0x13328
movq %rsp, %rsi
callq 0x79f7
testb %al, %al
je 0x899e
movl $0x4, (%r14)
jmp 0x8a35
leaq 0xa9e3(%rip), %rdi      # 0x13388
movq %rsp, %rsi
callq 0x79f7
testb %al, %al
je 0x89ba
movl $0x5, (%r14)
jmp 0x8a35
leaq 0xa997(%rip), %rdi      # 0x13358
movq %rsp, %rsi
callq 0x79f7
testb %al, %al
je 0x89d6
movl $0x3, (%r14)
jmp 0x8a35
movq 0x8(%rsp), %rax
movq %rax, 0x40(%rsp)
testq %rax, %rax
je 0x8a2e
movq (%rsp), %r12
movb $0x1, %al
xorl %r13d, %r13d
movsbl (%r12,%r13), %edi
leal -0x30(%rdi), %ecx
testb $0x1, %al
je 0x89ff
cmpl $0x9, %ecx
jbe 0x8a5f
cmpl $0xa, %ecx
setb %bpl
cmpb $0x5f, %dil
sete %r15b
callq 0x5340
orb %bpl, %r15b
movzbl %r15b, %ecx
orl %eax, %ecx
je 0x8ac6
incq %r13
xorl %eax, %eax
cmpq %r13, 0x40(%rsp)
jne 0x89ee
movl $0x1, (%r14)
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x8a50
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x5230
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x30(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x39dc(%rip), %rsi      # 0xc44c
leaq 0x3a19(%rip), %rdx      # 0xc490
leaq 0x20(%rsp), %rdi
callq 0x6386
movq 0x8(%rsp), %rdx
movq (%rsp), %rsi
leaq 0x20(%rsp), %rdi
callq 0x5090
movl $0x10, %edi
callq 0x5110
movq %rax, %r15
leaq 0x20(%rsp), %rsi
movq %rax, %rdi
callq 0x5350
movq 0xa53b(%rip), %rsi      # 0x12ff0
movq 0xa4fc(%rip), %rdx      # 0x12fb8
movq %r15, %rdi
callq 0x5370
jmp 0x8b2b
leaq 0x30(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x39ba(%rip), %rsi      # 0xc491
leaq 0x39f4(%rip), %rdx      # 0xc4d2
leaq 0x20(%rsp), %rdi
callq 0x6386
movq 0x8(%rsp), %rdx
movq (%rsp), %rsi
leaq 0x20(%rsp), %rdi
callq 0x5090
movl $0x10, %edi
callq 0x5110
movq %rax, %r15
leaq 0x20(%rsp), %rsi
movq %rax, %rdi
callq 0x5350
movq 0xa4d4(%rip), %rsi      # 0x12ff0
movq 0xa495(%rip), %rdx      # 0x12fb8
movq %r15, %rdi
callq 0x5370
jmp 0x8b2d
movq %r15, %rdi
movq %rax, %r14
callq 0x51a0
jmp 0x8b41
jmp 0x8b60
jmp 0x8b3e
movq %rax, %r14
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x8b63
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x5230
jmp 0x8b63
jmp 0x8b60
jmp 0x8b60
jmp 0x8b80
movq %rax, %r14
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x8b83
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x5230
jmp 0x8b83
movq %rax, %r14
movq %rbx, %rdi
callq 0x6356
movq %r14, %rdi
callq 0x5390
nop