// File: /workspace/github_cpp_makefile_star2_O2/CoinXu[P]reviser-compiler/src/parser.cpp
// Function: reviser::compiler::Parser::ConsumeDeclare()
Declare* Parser::ConsumeDeclare() {
    // data type & data type array
    if (Accept(TOKEN_DATA_TYPE)) {
      const string type = PreviousText();
      if (Accept(TOKEN_LEFT_BRACKET)) {
        return ConsumeDataTypeArrayDeclare(type);
      }
      return ConsumeDataTypeDeclare();
    }

    // struct & struct array
    // enum & enum array
    if (Accept(TOKEN_ID)) {
      // TODO support struct array type
      const Token type_id = tokenizer->Previous();
      const string id = type_id.text;
      DeclareType type = generator->descriptor->FindContextVariableTypeById(id);

      if (Accept(TOKEN_LEFT_BRACKET)) {
        if (type == DECLARE_STRUCT) {
          return ConsumeStructArrayDeclare(type_id);
        }

        if (type == DECLARE_ENUM) {
          return ConsumeEnumArrayDeclare(type_id);
        }

        RuntimeError("unknow array type [" + id + "]");
        return nullptr;
      }

      if (type == DECLARE_STRUCT) {
        return ConsumeStructDeclare();
      }

      if (type == DECLARE_ENUM) {
        return ConsumeEnumDeclare();
      }

      if (type == DECLARE_UNDEFINED) {
        RuntimeError("undefined type [" + id + "]");
        return nullptr;
      }

      RuntimeError("unknow type [" + id + "]");
      return nullptr;
    }

    RuntimeError("unexpected token");
    return nullptr;
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movq %rdi, %r14
xorl %esi, %esi
callq 0x3ada2
testb %al, %al
je 0x3b956
leaq -0x98(%rbp), %rdi
movq %r14, %rsi
callq 0x3b724
pushq $0x5b
popq %rsi
movq %r14, %rdi
callq 0x3ada2
testb %al, %al
je 0x3ba3e
leaq -0x158(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x35470
leaq -0x158(%rbp), %rsi
movq %r14, %rdi
callq 0x3bc3c
movq %rax, %r14
leaq -0x158(%rbp), %rdi
callq 0x35180
jmp 0x3ba49
pushq $0x4
popq %rsi
movq %r14, %rdi
callq 0x3ada2
testb %al, %al
je 0x3b9ff
movq (%r14), %rdi
callq 0x3da46
leaq -0x98(%rbp), %rdi
movq %rax, %rsi
callq 0x3cc8e
leaq -0x90(%rbp), %rbx
leaq -0x58(%rbp), %rdi
movq %rbx, %rsi
callq 0x35470
movq 0x8(%r14), %rax
movq 0x50(%rax), %r15
leaq -0x138(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x35470
leaq -0x138(%rbp), %rsi
movq %r15, %rdi
callq 0x412d0
movl %eax, %r15d
leaq -0x138(%rbp), %rdi
callq 0x35180
pushq $0x5b
popq %rsi
movq %r14, %rdi
callq 0x3ada2
testb %al, %al
je 0x3ba55
testl %r15d, %r15d
je 0x3ba7b
cmpl $0x1, %r15d
jne 0x3ba8f
leaq -0x98(%rbp), %rsi
movq %r14, %rdi
callq 0x3c35c
jmp 0x3bb24
leaq 0x1bbad(%rip), %rsi     # 0x575b3
leaq -0xb8(%rbp), %rdi
leaq -0x98(%rbp), %rdx
callq 0x35130
leaq -0xb8(%rbp), %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x3b4e8
leaq -0xb8(%rbp), %rdi
callq 0x35180
xorl %r14d, %r14d
jmp 0x3bb8e
movq %r14, %rdi
callq 0x3bd9a
movq %rax, %r14
leaq -0x98(%rbp), %rdi
jmp 0x3bb89
testl %r15d, %r15d
je 0x3bb1c
cmpl $0x2, %r15d
je 0x3bad7
cmpl $0x1, %r15d
jne 0x3bb29
movq %r14, %rdi
callq 0x3c52a
jmp 0x3bb24
leaq -0x98(%rbp), %rsi
movq %r14, %rdi
callq 0x3c4e6
jmp 0x3bb7a
leaq 0x1baea(%rip), %rsi     # 0x57580
leaq -0x38(%rbp), %rdi
leaq -0x58(%rbp), %rdx
callq 0x3aa1e
leaq 0x1cf68(%rip), %rdx     # 0x58a12
leaq -0x118(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x38f1f
leaq -0x118(%rbp), %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x3b4e8
leaq -0x118(%rbp), %rdi
jmp 0x3bb6c
leaq 0x1bab6(%rip), %rsi     # 0x57594
leaq -0x38(%rbp), %rdi
leaq -0x58(%rbp), %rdx
callq 0x3aa1e
leaq 0x1cf20(%rip), %rdx     # 0x58a12
leaq -0xf8(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x38f1f
leaq -0xf8(%rbp), %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x3b4e8
leaq -0xf8(%rbp), %rdi
jmp 0x3bb6c
movq %r14, %rdi
callq 0x3c760
movq %rax, %r14
jmp 0x3bb7d
leaq 0x1ba75(%rip), %rsi     # 0x575a5
leaq -0x38(%rbp), %rdi
leaq -0x58(%rbp), %rdx
callq 0x3aa1e
leaq 0x1cece(%rip), %rdx     # 0x58a12
leaq -0xd8(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x38f1f
leaq -0xd8(%rbp), %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x3b4e8
leaq -0xd8(%rbp), %rdi
callq 0x35180
leaq -0x38(%rbp), %rdi
callq 0x35180
xorl %r14d, %r14d
leaq -0x58(%rbp), %rdi
callq 0x35180
movq %rbx, %rdi
callq 0x35180
movq %r14, %rax
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
leaq -0xd8(%rbp), %rdi
jmp 0x3bbc9
movq %rax, %r14
leaq -0xf8(%rbp), %rdi
jmp 0x3bbc9
jmp 0x3bbd0
jmp 0x3bbd0
jmp 0x3bc13
jmp 0x3bc13
movq %rax, %r14
leaq -0x118(%rbp), %rdi
callq 0x35180
jmp 0x3bbd3
movq %rax, %r14
leaq -0x38(%rbp), %rdi
jmp 0x3bbe5
jmp 0x3bc13
movq %rax, %r14
leaq -0x138(%rbp), %rdi
callq 0x35180
jmp 0x3bc16
movq %rax, %r14
leaq -0x158(%rbp), %rdi
callq 0x35180
jmp 0x3bc27
movq %rax, %r14
leaq -0xb8(%rbp), %rdi
jmp 0x3bc2e
movq %rax, %r14
jmp 0x3bc33
movq %rax, %r14
jmp 0x3bc1f
movq %rax, %r14
leaq -0x58(%rbp), %rdi
callq 0x35180
movq %rbx, %rdi
jmp 0x3bc2e
movq %rax, %r14
leaq -0x98(%rbp), %rdi
callq 0x35180
movq %r14, %rdi
callq 0x355f0
nop