// File: /workspace/github_cpp_makefile_star2_O1/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 $0x58, %rsp
movq %rdi, %r14
movl $0x2, (%rdi)
leaq 0x8(%rdi), %rbx
movq %rbx, %rdi
callq 0x62a4
movq %rbx, %rdi
callq 0xb4e6
testb %al, %al
je 0x8b27
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0xb4ee
movq 0x8(%rsp), %rax
cmpb $0x22, (%rax)
jne 0x8a0f
movq 0x10(%rsp), %rcx
cmpb $0x22, -0x1(%rax,%rcx)
jne 0x8a0f
addq $-0x2, %rcx
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rsi
movl $0x1, %edx
callq 0x5250
leaq 0x28(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x8c6c
movq (%r14), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x8b0c
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x5230
jmp 0x8b0c
leaq 0xb8e2(%rip), %rdi      # 0x142f8
leaq 0x8(%rsp), %rsi
callq 0x7a57
testb %al, %al
je 0x8a30
movl $0x6, (%r14)
jmp 0x8b0c
leaq 0xb8f1(%rip), %rdi      # 0x14328
leaq 0x8(%rsp), %rsi
callq 0x7a57
testb %al, %al
je 0x8a51
movl $0x4, (%r14)
jmp 0x8b0c
leaq 0xb930(%rip), %rdi      # 0x14388
leaq 0x8(%rsp), %rsi
callq 0x7a57
testb %al, %al
je 0x8a72
movl $0x5, (%r14)
jmp 0x8b0c
leaq 0xb8df(%rip), %rdi      # 0x14358
leaq 0x8(%rsp), %rsi
callq 0x7a57
testb %al, %al
je 0x8a90
movl $0x3, (%r14)
jmp 0x8b0c
movq 0x10(%rsp), %rax
movq %rax, 0x50(%rsp)
testq %rax, %rax
je 0x8b05
movq 0x8(%rsp), %rax
movq %rax, 0x48(%rsp)
movb $0x1, %r13b
xorl %ebp, %ebp
movq 0x48(%rsp), %rax
movsbl (%rax,%rbp), %edi
leal -0x30(%rdi), %eax
testb $0x1, %r13b
je 0x8ac5
cmpl $0x9, %eax
jbe 0x8b36
cmpl $0xa, %eax
setb %r12b
cmpb $0x5f, %dil
sete %r15b
callq 0x5340
orb %r12b, %r15b
movzbl %r15b, %ecx
orl %eax, %ecx
je 0x8b9e
testb $0x1, %r13b
movzbl %r13b, %eax
movl $0x0, %ecx
cmovnel %ecx, %eax
incq %rbp
movl %eax, %r13d
cmpq %rbp, 0x50(%rsp)
jne 0x8aae
movl $0x1, (%r14)
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x8b27
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x5230
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x38(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x4919(%rip), %rsi      # 0xd460
leaq 0x4956(%rip), %rdx      # 0xd4a4
leaq 0x28(%rsp), %rdi
callq 0x6382
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
leaq 0x28(%rsp), %rdi
callq 0x5090
movl $0x10, %edi
callq 0x5110
movq %rax, %r15
leaq 0x28(%rsp), %rsi
movq %rax, %rdi
callq 0x5350
movq 0xb463(%rip), %rsi      # 0x13ff0
movq 0xb424(%rip), %rdx      # 0x13fb8
movq %r15, %rdi
callq 0x5370
jmp 0x8c04
leaq 0x38(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x48f6(%rip), %rsi      # 0xd4a5
leaq 0x4930(%rip), %rdx      # 0xd4e6
leaq 0x28(%rsp), %rdi
callq 0x6382
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
leaq 0x28(%rsp), %rdi
callq 0x5090
movl $0x10, %edi
callq 0x5110
movq %rax, %r15
leaq 0x28(%rsp), %rsi
movq %rax, %rdi
callq 0x5350
movq 0xb3fb(%rip), %rsi      # 0x13ff0
movq 0xb3bc(%rip), %rdx      # 0x13fb8
movq %r15, %rdi
callq 0x5370
jmp 0x8c06
movq %rax, %r14
movq %r15, %rdi
callq 0x51a0
jmp 0x8c1a
jmp 0x8c39
jmp 0x8c17
movq %rax, %r14
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0x8c3c
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x5230
jmp 0x8c3c
jmp 0x8c39
jmp 0x8c39
jmp 0x8c59
movq %rax, %r14
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x8c5c
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x5230
jmp 0x8c5c
movq %rax, %r14
movq %rbx, %rdi
callq 0x6352
movq %r14, %rdi
callq 0x5390