// File: /workspace/github_cpp_makefile_star2_O1/WayfireWM[P]wf-utils/wayfire/parser/condition_parser.cpp
// Function: wf::condition_parser_t::parse(wf::lexer_t&)
std::shared_ptr<condition_t> condition_parser_t::parse(lexer_t &lexer)
{
    // Peek at the first symbol to see if we consider a catch-all or catch-none condition.
    auto symbol = lexer.parse_symbol();
    lexer.reverse();

    if (symbol.type == symbol_t::type_t::KEYWORD)
    {
        auto keyword = get_string(symbol.value);
        if (keyword == "all")
        {
            _root = std::make_shared<true_condition_t>();
        }
        else if (keyword == "none")
        {
            _root = std::make_shared<false_condition_t>();
        }
        else
        {
            throw std::runtime_error("Condition parser error. Single keyword rules must be 'all' or 'none'.");
        }
    }
    else
    {
        _expression(lexer);
        lexer.reverse();
    }

    std::cout << _root->to_string() << std::endl;

    return _root;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x70, %rsp
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x40(%rsp), %rdi
movq %rdx, %rsi
callq 0x7384
movq %r15, %rdi
callq 0x77fa
cmpl $0x4, 0x40(%rsp)
jne 0x93ab
leaq 0x48(%rsp), %rsi
leaq 0x20(%rsp), %rdi
callq 0xb4ee
leaq 0x3e72(%rip), %rsi      # 0xd1d8
leaq 0x20(%rsp), %rdi
callq 0x5080
testl %eax, %eax
je 0x93c0
leaq 0x3e61(%rip), %rsi      # 0xd1dc
leaq 0x20(%rsp), %rdi
callq 0x5080
testl %eax, %eax
jne 0x94df
leaq 0x18(%rsp), %rdi
movq $0x0, -0x8(%rdi)
leaq 0x10(%rsp), %rsi
leaq 0xf(%rsp), %rdx
callq 0x9fb4
jmp 0x93dc
movq %r14, %rdi
movq %r15, %rsi
callq 0x9566
movq %r15, %rdi
callq 0x77fa
jmp 0x9429
leaq 0x18(%rsp), %rdi
movq $0x0, -0x8(%rdi)
leaq 0x10(%rsp), %rsi
leaq 0xf(%rsp), %rdx
callq 0x9eca
vmovaps 0x10(%rsp), %xmm0
vxorps %xmm1, %xmm1, %xmm1
vmovaps %xmm1, 0x10(%rsp)
movq 0x8(%r14), %rdi
vmovups %xmm0, (%r14)
testq %rdi, %rdi
je 0x93ff
callq 0x6968
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x940e
callq 0x6968
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9429
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x5230
movq (%r14), %rsi
movq (%rsi), %rax
leaq 0x20(%rsp), %rdi
callq *0x18(%rax)
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq 0xab80(%rip), %rdi      # 0x13fc8
callq 0x5270
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x5200
movsbl %al, %esi
movq %r15, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5160
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9492
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x5230
movq (%r14), %rax
movq %rax, (%rbx)
movq 0x8(%r14), %rax
movq %rax, 0x8(%rbx)
testq %rax, %rax
je 0x94ba
movq 0xab14(%rip), %rcx      # 0x13fc0
cmpb $0x0, (%rcx)
je 0x94b6
incl 0x8(%rax)
jmp 0x94ba
lock
incl 0x8(%rax)
leaq 0x48(%rsp), %rsi
movzbl 0x20(%rsi), %eax
leaq 0x9856(%rip), %rcx      # 0x12d20
leaq 0x20(%rsp), %rdi
callq *(%rcx,%rax,8)
movq %rbx, %rax
addq $0x70, %rsp
popq %rbx
popq %r14
popq %r15
retq
movl $0x10, %edi
callq 0x5110
movq %rax, %r14
leaq 0x40fd(%rip), %rsi      # 0xd5f0
movq %rax, %rdi
callq 0x50d0
movq 0xaaee(%rip), %rsi      # 0x13ff0
movq 0xaaaf(%rip), %rdx      # 0x13fb8
movq %r14, %rdi
callq 0x5370
jmp 0x9535
movq %rax, %rbx
movq %r14, %rdi
callq 0x51a0
jmp 0x9538
jmp 0x9535
jmp 0x9535
jmp 0x9530
movq %rax, %rdi
callq 0x6209
jmp 0x9530
movq %rax, %rbx
jmp 0x9553
movq %rax, %rbx
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9553
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x5230
leaq 0x40(%rsp), %rdi
callq 0x7562
movq %rbx, %rdi
callq 0x5390
nop