// File: 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:
subq $0x298, %rsp            # imm = 0x298
movq %rdi, 0x290(%rsp)
movq %rsi, 0x288(%rsp)
movq 0x290(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x288(%rsp), %rsi
leaq 0x258(%rsp), %rdi
callq 0xc270
movq 0x70(%rsp), %rdi
addq $0x10, %rdi
leaq 0x258(%rsp), %rsi
callq 0x12fc0
leaq 0x258(%rsp), %rdi
callq 0xc5f0
movq 0x70(%rsp), %rax
cmpl $0x1, 0x10(%rax)
je 0x14706
movq 0x70(%rsp), %rax
cmpl $0x6, 0x10(%rax)
jne 0x14b8b
movq 0x70(%rsp), %rsi
addq $0x18, %rsi
leaq 0x238(%rsp), %rdi
callq 0x1bea0
movq 0x288(%rsp), %rsi
leaq 0x208(%rsp), %rdi
callq 0xc270
jmp 0x14733
movq 0x70(%rsp), %rdi
addq $0x10, %rdi
leaq 0x208(%rsp), %rsi
callq 0x12fc0
leaq 0x208(%rsp), %rdi
callq 0xc5f0
movq 0x70(%rsp), %rax
cmpl $0x4, 0x10(%rax)
je 0x147dd
movl $0x10, %edi
callq 0x6170
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x68(%rsp)
leaq 0xaf99(%rip), %rsi      # 0x1f716
callq 0x6100
jmp 0x14784
movq 0x68(%rsp), %rdi
movq 0x1a860(%rip), %rsi     # 0x2eff0
movq 0x1a811(%rip), %rdx     # 0x2efa8
callq 0x64d0
jmp 0x14f63
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
jmp 0x14b79
movq 0x68(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
callq 0x6240
jmp 0x14b79
movq 0x70(%rsp), %rsi
addq $0x18, %rsi
leaq 0x1d8(%rsp), %rdi
callq 0x1bea0
jmp 0x147f5
leaq 0xa9db(%rip), %rsi      # 0x1f1d7
leaq 0x1d8(%rsp), %rdi
callq 0x15030
movb %al, 0x67(%rsp)
jmp 0x1480f
movb 0x67(%rsp), %al
testb $0x1, %al
jne 0x1481c
jmp 0x14981
leaq 0xa9bb(%rip), %rsi      # 0x1f1de
leaq 0x1d8(%rsp), %rdi
callq 0x15030
movb %al, 0x66(%rsp)
jmp 0x14836
movb 0x66(%rsp), %al
testb $0x1, %al
jne 0x14843
jmp 0x14981
leaq 0xa98a(%rip), %rsi      # 0x1f1d4
leaq 0x1d8(%rsp), %rdi
callq 0x15030
movb %al, 0x65(%rsp)
jmp 0x1485d
movb 0x65(%rsp), %al
testb $0x1, %al
jne 0x1486a
jmp 0x14981
leaq 0x1b7(%rsp), %rdi
movq %rdi, 0x58(%rsp)
callq 0x6500
movq 0x58(%rsp), %rdx
leaq 0xaeb8(%rip), %rsi      # 0x1f740
leaq 0x1b8(%rsp), %rdi
callq 0x8280
jmp 0x14897
leaq 0x1b7(%rsp), %rdi
callq 0x6360
leaq 0x1b8(%rsp), %rdi
leaq 0x1d8(%rsp), %rsi
callq 0x6560
jmp 0x148bb
movl $0x10, %edi
callq 0x6170
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x50(%rsp)
leaq 0x1b8(%rsp), %rsi
callq 0x64a0
jmp 0x148df
movq 0x50(%rsp), %rdi
movq 0x1a705(%rip), %rsi     # 0x2eff0
movq 0x1a6b6(%rip), %rdx     # 0x2efa8
callq 0x64d0
jmp 0x14f63
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
jmp 0x14b6c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
leaq 0x1b7(%rsp), %rdi
callq 0x6360
jmp 0x14b6c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
jmp 0x1496f
movq 0x50(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
callq 0x6240
leaq 0x1b8(%rsp), %rdi
callq 0x61d0
jmp 0x14b6c
movq 0x288(%rsp), %rsi
leaq 0x180(%rsp), %rdi
callq 0xc270
jmp 0x14998
movq 0x70(%rsp), %rdi
addq $0x10, %rdi
leaq 0x180(%rsp), %rsi
callq 0x12fc0
leaq 0x180(%rsp), %rdi
callq 0xc5f0
movq 0x70(%rsp), %rax
cmpl $0x2, 0x10(%rax)
je 0x14a29
movl $0x10, %edi
callq 0x6170
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x48(%rsp)
leaq 0xad95(%rip), %rsi      # 0x1f777
callq 0x6100
jmp 0x149e9
movq 0x48(%rsp), %rdi
movq 0x1a5fb(%rip), %rsi     # 0x2eff0
movq 0x1a5ac(%rip), %rdx     # 0x2efa8
callq 0x64d0
jmp 0x14f63
movq 0x48(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
callq 0x6240
jmp 0x14b6c
leaq 0xa7a7(%rip), %rsi      # 0x1f1d7
leaq 0x1d8(%rsp), %rdi
callq 0xcc20
movb %al, 0x47(%rsp)
jmp 0x14a43
movb 0x47(%rsp), %al
testb $0x1, %al
jne 0x14a71
jmp 0x14a4d
leaq 0xa780(%rip), %rsi      # 0x1f1d4
leaq 0x1d8(%rsp), %rdi
callq 0xcc20
movb %al, 0x46(%rsp)
jmp 0x14a67
movb 0x46(%rsp), %al
testb $0x1, %al
jne 0x14a71
jmp 0x14ab0
movq 0x70(%rsp), %rdx
addq $0x18, %rdx
leaq 0x170(%rsp), %rdi
leaq 0x238(%rsp), %rsi
callq 0x15060
jmp 0x14a91
movq 0x70(%rsp), %rdi
leaq 0x170(%rsp), %rsi
callq 0x150e0
leaq 0x170(%rsp), %rdi
callq 0x15110
leaq 0xa727(%rip), %rsi      # 0x1f1de
leaq 0x1d8(%rsp), %rdi
callq 0xcc20
movb %al, 0x45(%rsp)
jmp 0x14aca
movb 0x45(%rsp), %al
testb $0x1, %al
jne 0x14ad4
jmp 0x14b13
movq 0x70(%rsp), %rdx
addq $0x18, %rdx
leaq 0x160(%rsp), %rdi
leaq 0x238(%rsp), %rsi
callq 0x15120
jmp 0x14af4
movq 0x70(%rsp), %rdi
leaq 0x160(%rsp), %rsi
callq 0x151a0
leaq 0x160(%rsp), %rdi
callq 0x151d0
movq 0x288(%rsp), %rsi
leaq 0x130(%rsp), %rdi
callq 0xc270
jmp 0x14b2a
movq 0x70(%rsp), %rdi
addq $0x10, %rdi
leaq 0x130(%rsp), %rsi
callq 0x12fc0
leaq 0x130(%rsp), %rdi
callq 0xc5f0
leaq 0x1d8(%rsp), %rdi
callq 0x61d0
leaq 0x238(%rsp), %rdi
callq 0x61d0
jmp 0x14f4e
leaq 0x1d8(%rsp), %rdi
callq 0x61d0
leaq 0x238(%rsp), %rdi
callq 0x61d0
jmp 0x14f56
movq 0x70(%rsp), %rax
movl 0x10(%rax), %ecx
movb $0x0, 0x10f(%rsp)
xorl %eax, %eax
cmpl $0x3, %ecx
movb %al, 0x44(%rsp)
jne 0x14bea
movq 0x70(%rsp), %rsi
addq $0x18, %rsi
leaq 0x110(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0x1bea0
movq 0x38(%rsp), %rdi
movb $0x1, 0x10f(%rsp)
leaq 0xa498(%rip), %rsi      # 0x1f06d
callq 0xcc20
movb %al, 0x43(%rsp)
jmp 0x14be0
movb 0x43(%rsp), %al
movb %al, 0x44(%rsp)
jmp 0x14bea
movb 0x44(%rsp), %al
movb %al, 0x37(%rsp)
testb $0x1, 0x10f(%rsp)
jne 0x14bfe
jmp 0x14c0b
leaq 0x110(%rsp), %rdi
callq 0x61d0
movb 0x37(%rsp), %al
testb $0x1, %al
jne 0x14c18
jmp 0x14cd3
leaq 0xf8(%rsp), %rdi
callq 0x151e0
movq 0x70(%rsp), %rdi
movq 0x288(%rsp), %rsi
callq 0x14690
jmp 0x14c39
leaq 0xf8(%rsp), %rdi
callq 0x15250
movq 0x70(%rsp), %rsi
movq %rax, %rdi
addq $0x8, %rdi
callq 0x14620
movq 0x70(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
callq 0x15260
leaq 0xf8(%rsp), %rdi
callq 0x15290
jmp 0x14f4c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
testb $0x1, 0x10f(%rsp)
jne 0x14c9b
jmp 0x14ca8
leaq 0x110(%rsp), %rdi
callq 0x61d0
jmp 0x14f56
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
leaq 0xf8(%rsp), %rdi
callq 0x15290
jmp 0x14f56
movq 0x70(%rsp), %rax
movl 0x10(%rax), %ecx
movb $0x0, 0xd7(%rsp)
xorl %eax, %eax
cmpl $0x5, %ecx
movb %al, 0x36(%rsp)
jne 0x14d32
movq 0x70(%rsp), %rsi
addq $0x18, %rsi
leaq 0xd8(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x1bea0
movq 0x28(%rsp), %rdi
movb $0x1, 0xd7(%rsp)
leaq 0xb224(%rip), %rsi      # 0x1ff41
callq 0xcc20
movb %al, 0x35(%rsp)
jmp 0x14d28
movb 0x35(%rsp), %al
movb %al, 0x36(%rsp)
jmp 0x14d32
movb 0x36(%rsp), %al
movb %al, 0x27(%rsp)
testb $0x1, 0xd7(%rsp)
jne 0x14d46
jmp 0x14d53
leaq 0xd8(%rsp), %rdi
callq 0x61d0
movb 0x27(%rsp), %al
testb $0x1, %al
jne 0x14d60
jmp 0x14ef2
movq 0x70(%rsp), %rdi
movq 0x288(%rsp), %rsi
callq 0x14290
movq 0x70(%rsp), %rax
movl 0x10(%rax), %ecx
movb $0x0, 0xaf(%rsp)
movb $0x1, %al
cmpl $0x5, %ecx
movb %al, 0x26(%rsp)
jne 0x14dd1
movq 0x70(%rsp), %rsi
addq $0x18, %rsi
leaq 0xb0(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x1bea0
movq 0x18(%rsp), %rdi
movb $0x1, 0xaf(%rsp)
leaq 0xb15a(%rip), %rsi      # 0x1ff16
callq 0x15030
movb %al, 0x25(%rsp)
jmp 0x14dc7
movb 0x25(%rsp), %al
movb %al, 0x26(%rsp)
jmp 0x14dd1
movb 0x26(%rsp), %al
movb %al, 0x17(%rsp)
testb $0x1, 0xaf(%rsp)
jne 0x14de5
jmp 0x14df2
leaq 0xb0(%rsp), %rdi
callq 0x61d0
movb 0x17(%rsp), %al
testb $0x1, %al
jne 0x14dff
jmp 0x14ec1
movl $0x10, %edi
callq 0x6170
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x8(%rsp)
leaq 0xa986(%rip), %rsi      # 0x1f7a1
callq 0x6100
jmp 0x14e22
movq 0x8(%rsp), %rdi
movq 0x1a1c2(%rip), %rsi     # 0x2eff0
movq 0x1a173(%rip), %rdx     # 0x2efa8
callq 0x64d0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
testb $0x1, 0xd7(%rsp)
jne 0x14e5a
jmp 0x14e67
leaq 0xd8(%rsp), %rdi
callq 0x61d0
jmp 0x14f56
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
testb $0x1, 0xaf(%rsp)
jne 0x14e8c
jmp 0x14e99
leaq 0xb0(%rsp), %rdi
callq 0x61d0
jmp 0x14f56
movq 0x8(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
callq 0x6240
jmp 0x14f56
movq 0x288(%rsp), %rsi
leaq 0x78(%rsp), %rdi
callq 0xc270
movq 0x70(%rsp), %rdi
addq $0x10, %rdi
leaq 0x78(%rsp), %rsi
callq 0x12fc0
leaq 0x78(%rsp), %rdi
callq 0xc5f0
jmp 0x14f4a
movl $0x10, %edi
callq 0x6170
movq %rax, %rdi
movq %rdi, %rax
movq %rax, (%rsp)
leaq 0xa8b9(%rip), %rsi      # 0x1f7c6
callq 0x6100
jmp 0x14f14
movq (%rsp), %rdi
movq 0x1a0d1(%rip), %rsi     # 0x2eff0
movq 0x1a082(%rip), %rdx     # 0x2efa8
callq 0x64d0
movq (%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
callq 0x6240
jmp 0x14f56
jmp 0x14f4c
jmp 0x14f4e
addq $0x298, %rsp            # imm = 0x298
retq
movq 0x200(%rsp), %rdi
callq 0x64f0
nopw %cs:(%rax,%rax)
nopl (%rax)