// File: /workspace/github_cpp_makefile_star2_O2/WayfireWM[P]wf-utils/wayfire/parser/condition_parser.cpp
// Function: wf::condition_parser_t::_factor(wf::lexer_t&)
void condition_parser_t::_factor(lexer_t &lexer)
{
    _symbol = lexer.parse_symbol();

    if (_symbol.type == symbol_t::type_t::IDENTIFIER || _symbol.type == symbol_t::type_t::SIGNAL)
    {
        // Identifier.
        auto identifier = get_string(_symbol.value);

        // Keyword.
        _symbol = lexer.parse_symbol();
        if (_symbol.type != symbol_t::type_t::KEYWORD)
        {
            throw std::runtime_error("Condition parser error. Expected keyword.");
        }
        auto keyword = get_string(_symbol.value);
        if ((keyword != "equals") && (keyword != "contains") && (keyword != "is"))
        {
            std::string error = "Condition parser error. Unsupported keyword. keyword: ";
            error.append(keyword);
            throw std::runtime_error(error);
        }

        // Value.
        _symbol = lexer.parse_symbol();
        if (_symbol.type != symbol_t::type_t::LITERAL)
        {
            throw std::runtime_error("Condition parser error. Expected literal.");
        }

        // Create condition.
        if (keyword == "equals" || keyword == "is")
        {
            _root = std::make_shared<equals_condition_t>(identifier, _symbol.value);
        }
        if (keyword == "contains")
        {
            _root = std::make_shared<contains_condition_t>(identifier, _symbol.value);
        }

        _symbol = lexer.parse_symbol();
    }
    else if ((_symbol.type == symbol_t::type_t::OPERATOR) && (get_string(_symbol.value) == "!"))
    {
        auto not_condition = std::make_shared<not_condition_t>();
        _factor(lexer);
        not_condition->child = _root;
        _root = not_condition;
    }
    else if ((_symbol.type == symbol_t::type_t::STRUCTURAL) && (get_string(_symbol.value) == "("))
    {
        _expression(lexer);
        // Expect ) and discard it
        if (_symbol.type != symbol_t::type_t::STRUCTURAL || (get_string(_symbol.value) != ")"))
        {
            throw std::runtime_error("Condition parser error. Expected \')\'");
        }
        _symbol = lexer.parse_symbol();
    }
    else {
        throw std::runtime_error("Condition parser error. Unexpected symbol.");
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
leaq 0x8(%rsp), %r12
movq %rdi, %r15
movq %rsi, %rbx
movq %r12, %rdi
callq 0x6fde
leaq 0x10(%r15), %r14
movq %r12, %rsi
movq %r14, %rdi
callq 0x89ca
leaq 0x10(%rsp), %rdi
callq 0x62d0
movl 0x10(%r15), %eax
cmpl $0x6, %eax
je 0x9011
cmpl $0x3, %eax
je 0x919c
cmpl $0x1, %eax
jne 0x9211
leaq 0x18(%r15), %r12
leaq 0x58(%rsp), %rdi
movq %r12, %rsi
callq 0xad75
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x6fde
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x89ca
leaq 0x10(%rsp), %rdi
callq 0x62d0
cmpl $0x4, (%r14)
jne 0x930c
leaq 0x38(%rsp), %rdi
movq %r12, %rsi
callq 0xad75
leaq 0x3154(%rip), %rsi      # 0xc1b8
leaq 0x38(%rsp), %rdi
callq 0x9467
testb %al, %al
je 0x90a0
leaq 0x3146(%rip), %rsi      # 0xc1bf
leaq 0x38(%rsp), %rdi
callq 0x9467
testb %al, %al
je 0x90a0
leaq 0x3127(%rip), %rsi      # 0xc1b5
leaq 0x38(%rsp), %rdi
callq 0x9467
testb %al, %al
jne 0x9373
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x6fde
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x89ca
leaq 0x10(%rsp), %rdi
callq 0x62d0
cmpl $0x2, (%r14)
jne 0x9341
leaq 0x30e3(%rip), %rsi      # 0xc1b8
leaq 0x38(%rsp), %rdi
callq 0x73a5
testb %al, %al
jne 0x90f8
leaq 0x30cb(%rip), %rsi      # 0xc1b5
leaq 0x38(%rsp), %rdi
callq 0x73a5
testb %al, %al
je 0x9121
leaq 0x8(%rsp), %rdi
leaq 0x58(%rsp), %rsi
movq %r12, %rdx
callq 0x9471
leaq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0x9d62
leaq 0x10(%rsp), %rdi
callq 0x67d4
leaq 0x3097(%rip), %rsi      # 0xc1bf
leaq 0x38(%rsp), %rdi
callq 0x73a5
testb %al, %al
je 0x915f
leaq 0x8(%rsp), %rdi
leaq 0x58(%rsp), %rsi
movq %r12, %rdx
callq 0x9492
leaq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0x9f1e
leaq 0x10(%rsp), %rdi
callq 0x67d4
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x6fde
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x89ca
leaq 0x10(%rsp), %rdi
callq 0x62d0
leaq 0x38(%rsp), %rdi
callq 0x50e0
leaq 0x58(%rsp), %rdi
callq 0x50e0
jmp 0x92b1
leaq 0x8(%rsp), %r12
leaq 0x18(%r15), %rsi
movq %r12, %rdi
callq 0xad75
leaq 0x2eb9(%rip), %rsi      # 0xc06d
movq %r12, %rdi
callq 0x73a5
movq %r12, %rdi
movl %eax, %ebp
callq 0x50e0
testb %bpl, %bpl
je 0x920e
leaq 0x8(%rsp), %rdi
callq 0x94b3
movq %r15, %rdi
movq %rbx, %rsi
callq 0x8fbc
leaq 0x8(%rsp), %rbx
movq %r15, %rsi
movq (%rbx), %rdi
addq $0x8, %rdi
callq 0x9502
movq %r15, %rdi
movq %rbx, %rsi
callq 0xa0bc
leaq 0x10(%rsp), %rdi
callq 0x67d4
jmp 0x92b1
movl (%r14), %eax
cmpl $0x5, %eax
jne 0x92c0
leaq 0x18(%r15), %r12
leaq 0x8(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0xad75
leaq 0x3bd9(%rip), %rsi      # 0xce0e
movq %r13, %rdi
callq 0x73a5
movq %r13, %rdi
movl %eax, %ebp
callq 0x50e0
testb %bpl, %bpl
je 0x92c0
movq %r15, %rdi
movq %rbx, %rsi
callq 0x8e14
cmpl $0x5, 0x10(%r15)
jne 0x92dc
leaq 0x8(%rsp), %r15
movq %r12, %rsi
movq %r15, %rdi
callq 0xad75
leaq 0x3b6e(%rip), %rsi      # 0xcde3
movq %r15, %rdi
callq 0x9467
movq %r15, %rdi
movl %eax, %ebp
callq 0x50e0
testb %bpl, %bpl
jne 0x92dc
leaq 0x8(%rsp), %r15
movq %rbx, %rsi
movq %r15, %rdi
callq 0x6fde
movq %r14, %rdi
movq %r15, %rsi
callq 0x89ca
leaq 0x10(%rsp), %rdi
callq 0x62d0
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x5100
movq %rax, %r14
leaq 0x33bc(%rip), %rsi      # 0xc68e
movq %rax, %rdi
callq 0x50a0
jmp 0x92f6
pushq $0x10
popq %rdi
callq 0x5100
movq %rax, %r14
leaq 0x337b(%rip), %rsi      # 0xc669
movq %rax, %rdi
callq 0x50a0
movq 0xacf3(%rip), %rsi      # 0x13ff0
movq 0xaca4(%rip), %rdx      # 0x13fa8
movq %r14, %rdi
callq 0x5320
pushq $0x10
popq %rdi
callq 0x5100
movq %rax, %r14
leaq 0x32c0(%rip), %rsi      # 0xc5de
movq %rax, %rdi
callq 0x50a0
movq 0xacc3(%rip), %rsi      # 0x13ff0
movq 0xac74(%rip), %rdx      # 0x13fa8
movq %r14, %rdi
callq 0x5320
jmp 0x93c6
pushq $0x10
popq %rdi
callq 0x5100
movq %rax, %r14
leaq 0x32ec(%rip), %rsi      # 0xc63f
movq %rax, %rdi
callq 0x50a0
movq 0xac8e(%rip), %rsi      # 0x13ff0
movq 0xac3f(%rip), %rdx      # 0x13fa8
movq %r14, %rdi
callq 0x5320
jmp 0x93c6
leaq 0x328e(%rip), %rsi      # 0xc608
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x61ca
leaq 0x8(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x5390
pushq $0x10
popq %rdi
callq 0x5100
movq %rax, %r14
leaq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x5300
movq 0xac39(%rip), %rsi      # 0x13ff0
movq 0xabea(%rip), %rdx      # 0x13fa8
movq %r14, %rdi
callq 0x5320
movq %r14, %rdi
movq %rax, %rbx
callq 0x5180
jmp 0x93d6
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x50e0
jmp 0x9429
jmp 0x9426
leaq 0x10(%rsp), %rdi
movq %rax, %rbx
callq 0x67d4
jmp 0x9444
jmp 0x9426
jmp 0x9426
movq %r14, %rdi
movq %rax, %rbx
callq 0x5180
jmp 0x9429
jmp 0x9437
movq %r14, %rdi
movq %rax, %rbx
callq 0x5180
jmp 0x943a
jmp 0x9426
jmp 0x9417
movq %r14, %rdi
movq %rax, %rbx
callq 0x5180
jmp 0x9444
jmp 0x9426
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x50e0
jmp 0x943a
jmp 0x9437
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x50e0
movq %rbx, %rdi
callq 0x5340