// File: WayfireWM[P]wf-utils/wayfire/lexer/lexer.cpp
// Function: wf::lexer_t::_parse_literal[abi:cxx11]()
variant_t lexer_t::_parse_literal()
{
    // Catch out char and string literals first.
    auto c = _text.substr(_parse_position, 1);
    if ((c == "\'") || (c == "\""))
    {
        return _parse_encapsulated_literal(c, c);
    }

    // It is possible that the literal is 1 character long (Structures and operators).
    if ((contains(OPERATORS, c)) || (contains(STRUCTURES, c)))
    {
         ++_parse_position;
        return parse_literal(c);
    }

    // A literal is denoted from _position until the first occurrence of one of ')', '(', '&', '|', '!', ' ', '"', '\''
    auto end = std::string::npos;
    for (const auto &s : OPERATORS)
    {
        end = std::min(end, _text.find(s, _parse_position));
    }
    for (const auto &s : STRUCTURES)
    {
        end = std::min(end, _text.find(s, _parse_position));
    }
    for (const auto &s : DELIMITERS)
    {
        end = std::min(end, _text.find(s, _parse_position));
    }

    // If we found none of them, the literal ends at the end of _text
    if (end == std::string::npos)
    {
        end = _size;
    }

    // At this point we know that the literal we want is between _parse_position and end. Extract and return.
    auto length = end - _parse_position;
    auto literal_text = _text.substr(_parse_position, length);
    _parse_position += length;
    return parse_literal(literal_text);
}

// Assembly:
subq $0x138, %rsp            # imm = 0x138
movq %rdi, 0x28(%rsp)
movq %rdi, %rax
movq %rax, 0x30(%rsp)
movq %rdi, 0x130(%rsp)
movq %rsi, 0x128(%rsp)
movq 0x128(%rsp), %rax
movq %rax, 0x38(%rsp)
movq %rax, %rsi
addq $0x8, %rsi
movq 0x28(%rax), %rdx
leaq 0x108(%rsp), %rdi
movq %rdi, 0x40(%rsp)
movl $0x1, %ecx
callq 0x6320
movq 0x40(%rsp), %rdi
leaq 0x13135(%rip), %rsi     # 0x1f7c4
callq 0xcc20
movb %al, 0x4f(%rsp)
jmp 0xc69a
movb 0x4f(%rsp), %al
testb $0x1, %al
jne 0xc6c8
jmp 0xc6a4
leaq 0x12b59(%rip), %rsi     # 0x1f204
leaq 0x108(%rsp), %rdi
callq 0xcc20
movb %al, 0x27(%rsp)
jmp 0xc6be
movb 0x27(%rsp), %al
testb $0x1, %al
jne 0xc6c8
jmp 0xc70d
movq 0x38(%rsp), %rsi
movq 0x28(%rsp), %rdi
leaq 0x108(%rsp), %rcx
movq %rcx, %rdx
callq 0xcc50
jmp 0xc6e4
movl $0x1, 0xf8(%rsp)
jmp 0xcaa3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x100(%rsp)
movl %eax, 0xfc(%rsp)
jmp 0xcabd
leaq 0x22c44(%rip), %rdi     # 0x2f358
leaq 0x108(%rsp), %rsi
callq 0xcf60
movb %al, 0x26(%rsp)
jmp 0xc727
movb 0x26(%rsp), %al
testb $0x1, %al
jne 0xc755
jmp 0xc731
leaq 0x22c50(%rip), %rdi     # 0x2f388
leaq 0x108(%rsp), %rsi
callq 0xcf60
movb %al, 0x25(%rsp)
jmp 0xc74b
movb 0x25(%rsp), %al
testb $0x1, %al
jne 0xc755
jmp 0xc789
movq 0x28(%rsp), %rdi
movq 0x38(%rsp), %rax
movq 0x28(%rax), %rcx
incq %rcx
movq %rcx, 0x28(%rax)
leaq 0x108(%rsp), %rsi
callq 0x10160
jmp 0xc779
movl $0x1, 0xf8(%rsp)
jmp 0xcaa3
movq $-0x1, 0xf0(%rsp)
leaq 0x22bbc(%rip), %rax     # 0x2f358
movq %rax, 0xe8(%rsp)
leaq 0x22bad(%rip), %rdi     # 0x2f358
callq 0xcfd0
movq %rax, 0xe0(%rsp)
leaq 0x22b99(%rip), %rdi     # 0x2f358
callq 0xd000
movq %rax, 0xd8(%rsp)
leaq 0xe0(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0xd030
testb $0x1, %al
jne 0xc7e7
jmp 0xc862
leaq 0xe0(%rsp), %rdi
callq 0xd050
movq %rax, %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0xd0(%rsp)
movq %rax, %rdi
addq $0x8, %rdi
movq 0xd0(%rsp), %rsi
movq 0x28(%rax), %rdx
callq 0xd0b0
movq %rax, 0xc8(%rsp)
leaq 0xf0(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0xd070
movq %rax, 0x18(%rsp)
jmp 0xc840
movq 0x18(%rsp), %rax
movq (%rax), %rax
movq %rax, 0xf0(%rsp)
leaq 0xe0(%rsp), %rdi
callq 0xd130
jmp 0xc7cc
leaq 0x22b1f(%rip), %rax     # 0x2f388
movq %rax, 0xc0(%rsp)
leaq 0x22b10(%rip), %rdi     # 0x2f388
callq 0xcfd0
movq %rax, 0xb8(%rsp)
leaq 0x22afc(%rip), %rdi     # 0x2f388
callq 0xd000
movq %rax, 0xb0(%rsp)
leaq 0xb8(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0xd030
testb $0x1, %al
jne 0xc8b4
jmp 0xc92f
leaq 0xb8(%rsp), %rdi
callq 0xd050
movq %rax, %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0xa8(%rsp)
movq %rax, %rdi
addq $0x8, %rdi
movq 0xa8(%rsp), %rsi
movq 0x28(%rax), %rdx
callq 0xd0b0
movq %rax, 0xa0(%rsp)
leaq 0xf0(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0xd070
movq %rax, 0x10(%rsp)
jmp 0xc90d
movq 0x10(%rsp), %rax
movq (%rax), %rax
movq %rax, 0xf0(%rsp)
leaq 0xb8(%rsp), %rdi
callq 0xd130
jmp 0xc899
leaq 0x22a82(%rip), %rax     # 0x2f3b8
movq %rax, 0x98(%rsp)
leaq 0x22a73(%rip), %rdi     # 0x2f3b8
callq 0xcfd0
movq %rax, 0x90(%rsp)
leaq 0x22a5f(%rip), %rdi     # 0x2f3b8
callq 0xd000
movq %rax, 0x88(%rsp)
leaq 0x90(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0xd030
testb $0x1, %al
jne 0xc981
jmp 0xc9f6
leaq 0x90(%rsp), %rdi
callq 0xd050
movq %rax, %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x80(%rsp)
movq %rax, %rdi
addq $0x8, %rdi
movq 0x80(%rsp), %rsi
movq 0x28(%rax), %rdx
callq 0xd0b0
movq %rax, 0x78(%rsp)
leaq 0xf0(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0xd070
movq %rax, 0x8(%rsp)
jmp 0xc9d4
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq %rax, 0xf0(%rsp)
leaq 0x90(%rsp), %rdi
callq 0xd130
jmp 0xc966
cmpq $-0x1, 0xf0(%rsp)
jne 0xca11
movq 0x38(%rsp), %rax
movq (%rax), %rax
movq %rax, 0xf0(%rsp)
movq 0x38(%rsp), %rax
movq 0xf0(%rsp), %rcx
movq 0x28(%rax), %rdx
subq %rdx, %rcx
movq %rcx, 0x70(%rsp)
movq %rax, %rsi
addq $0x8, %rsi
movq 0x28(%rax), %rdx
movq 0x70(%rsp), %rcx
leaq 0x50(%rsp), %rdi
callq 0x6320
jmp 0xca46
movq 0x28(%rsp), %rdi
movq 0x38(%rsp), %rax
movq 0x70(%rsp), %rdx
movq 0x28(%rax), %rcx
addq %rdx, %rcx
movq %rcx, 0x28(%rax)
leaq 0x50(%rsp), %rsi
callq 0x10160
jmp 0xca6c
movl $0x1, 0xf8(%rsp)
leaq 0x50(%rsp), %rdi
callq 0x61d0
jmp 0xcaa3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x100(%rsp)
movl %eax, 0xfc(%rsp)
leaq 0x50(%rsp), %rdi
callq 0x61d0
jmp 0xcabd
leaq 0x108(%rsp), %rdi
callq 0x61d0
movq 0x30(%rsp), %rax
addq $0x138, %rsp            # imm = 0x138
retq
leaq 0x108(%rsp), %rdi
callq 0x61d0
movq 0x100(%rsp), %rdi
callq 0x64f0
nopw (%rax,%rax)