// File: 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
subq $0x230, %rsp            # imm = 0x230
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x1e0(%rbp)
xorl %esi, %esi
callq 0xa75f0
testb $0x1, %al
jne 0xa890a
jmp 0xa89ec
movq -0x1e0(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0xa8610
movq -0x1e0(%rbp), %rdi
movl $0x5b, %esi
callq 0xa75f0
movb %al, -0x1e1(%rbp)
jmp 0xa8933
movb -0x1e1(%rbp), %al
testb $0x1, %al
jne 0xa893f
jmp 0xa89a9
leaq -0x60(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x991c0
jmp 0xa894e
movq -0x1e0(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0xa8f00
movq %rax, -0x1f0(%rbp)
jmp 0xa8967
movq -0x1f0(%rbp), %rax
movq %rax, -0x8(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x992c0
movl $0x1, -0x64(%rbp)
jmp 0xa89d0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xa89de
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x992c0
jmp 0xa89de
movq -0x1e0(%rbp), %rdi
callq 0xa91c0
movq %rax, -0x1f8(%rbp)
jmp 0xa89be
movq -0x1f8(%rbp), %rax
movq %rax, -0x8(%rbp)
movl $0x1, -0x64(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x992c0
jmp 0xa8edb
leaq -0x30(%rbp), %rdi
callq 0x992c0
jmp 0xa8ee8
movq -0x1e0(%rbp), %rdi
movl $0x4, %esi
callq 0xa75f0
testb $0x1, %al
jne 0xa8a06
jmp 0xa8e3d
movq -0x1e0(%rbp), %rax
movq (%rax), %rdi
callq 0xae520
movq %rax, %rsi
leaq -0xa8(%rbp), %rdi
callq 0xaade0
leaq -0xa0(%rbp), %rsi
leaq -0xc8(%rbp), %rdi
callq 0x991c0
jmp 0xa8a39
movq -0x1e0(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x50(%rax), %rax
movq %rax, -0x200(%rbp)
leaq -0xf0(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x991c0
jmp 0xa8a64
movq -0x200(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0xbcee0
movl %eax, -0x204(%rbp)
jmp 0xa8a7f
leaq -0xf0(%rbp), %rdi
callq 0x992c0
movl -0x204(%rbp), %eax
movq -0x1e0(%rbp), %rdi
movl %eax, -0xcc(%rbp)
movl $0x5b, %esi
callq 0xa75f0
movb %al, -0x205(%rbp)
jmp 0xa8ab0
movb -0x205(%rbp), %al
testb $0x1, %al
jne 0xa8abf
jmp 0xa8c2a
cmpl $0x1, -0xcc(%rbp)
jne 0xa8b3a
movq -0x1e0(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0xa9d40
movq %rax, -0x210(%rbp)
jmp 0xa8ae4
movq -0x210(%rbp), %rax
movq %rax, -0x8(%rbp)
movl $0x1, -0x64(%rbp)
jmp 0xa8e03
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xa8e2c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xa8e20
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x992c0
jmp 0xa8e20
cmpl $0x0, -0xcc(%rbp)
jne 0xa8b76
movq -0x1e0(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0xaa030
movq %rax, -0x218(%rbp)
jmp 0xa8b5f
movq -0x218(%rbp), %rax
movq %rax, -0x8(%rbp)
movl $0x1, -0x64(%rbp)
jmp 0xa8e03
leaq 0x569b3(%rip), %rsi     # 0xff530
leaq -0x130(%rbp), %rdi
leaq -0xc8(%rbp), %rdx
callq 0xa6e30
jmp 0xa8b92
leaq 0x57ee9(%rip), %rdx     # 0x100a82
leaq -0x110(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0xa10c0
jmp 0xa8bae
movq -0x1e0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
leaq -0x110(%rbp), %rsi
callq 0xa82a0
jmp 0xa8bc7
leaq -0x110(%rbp), %rdi
callq 0x992c0
leaq -0x130(%rbp), %rdi
callq 0x992c0
movq $0x0, -0x8(%rbp)
movl $0x1, -0x64(%rbp)
jmp 0xa8e03
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xa8c19
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x992c0
leaq -0x130(%rbp), %rdi
callq 0x992c0
jmp 0xa8e20
cmpl $0x1, -0xcc(%rbp)
jne 0xa8c5f
movq -0x1e0(%rbp), %rdi
callq 0xaa0a0
movq %rax, -0x220(%rbp)
jmp 0xa8c48
movq -0x220(%rbp), %rax
movq %rax, -0x8(%rbp)
movl $0x1, -0x64(%rbp)
jmp 0xa8e03
cmpl $0x0, -0xcc(%rbp)
jne 0xa8c94
movq -0x1e0(%rbp), %rdi
callq 0xaa4f0
movq %rax, -0x228(%rbp)
jmp 0xa8c7d
movq -0x228(%rbp), %rax
movq %rax, -0x8(%rbp)
movl $0x1, -0x64(%rbp)
jmp 0xa8e03
cmpl $0x2, -0xcc(%rbp)
jne 0xa8d55
leaq 0x5689c(%rip), %rsi     # 0xff544
leaq -0x170(%rbp), %rdi
leaq -0xc8(%rbp), %rdx
callq 0xa6e30
jmp 0xa8cbd
leaq 0x57dbe(%rip), %rdx     # 0x100a82
leaq -0x150(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0xa10c0
jmp 0xa8cd9
movq -0x1e0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
leaq -0x150(%rbp), %rsi
callq 0xa82a0
jmp 0xa8cf2
leaq -0x150(%rbp), %rdi
callq 0x992c0
leaq -0x170(%rbp), %rdi
callq 0x992c0
movq $0x0, -0x8(%rbp)
movl $0x1, -0x64(%rbp)
jmp 0xa8e03
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xa8d44
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x150(%rbp), %rdi
callq 0x992c0
leaq -0x170(%rbp), %rdi
callq 0x992c0
jmp 0xa8e20
leaq 0x567f9(%rip), %rsi     # 0xff555
leaq -0x1b0(%rbp), %rdi
leaq -0xc8(%rbp), %rdx
callq 0xa6e30
jmp 0xa8d71
leaq 0x57d0a(%rip), %rdx     # 0x100a82
leaq -0x190(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
callq 0xa10c0
jmp 0xa8d8d
movq -0x1e0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
leaq -0x190(%rbp), %rsi
callq 0xa82a0
jmp 0xa8da6
leaq -0x190(%rbp), %rdi
callq 0x992c0
leaq -0x1b0(%rbp), %rdi
callq 0x992c0
movq $0x0, -0x8(%rbp)
movl $0x1, -0x64(%rbp)
jmp 0xa8e03
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xa8df5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x190(%rbp), %rdi
callq 0x992c0
leaq -0x1b0(%rbp), %rdi
callq 0x992c0
jmp 0xa8e20
leaq -0xc8(%rbp), %rdi
callq 0x992c0
leaq -0xa8(%rbp), %rdi
callq 0xa0bf0
jmp 0xa8edb
leaq -0xc8(%rbp), %rdi
callq 0x992c0
leaq -0xa8(%rbp), %rdi
callq 0xa0bf0
jmp 0xa8ee8
leaq -0x1d1(%rbp), %rdi
movq %rdi, -0x230(%rbp)
callq 0x99850
movq -0x230(%rbp), %rdx
leaq 0x56705(%rip), %rsi     # 0xff563
leaq -0x1d0(%rbp), %rdi
callq 0x99640
jmp 0xa8e6c
movq -0x1e0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
leaq -0x1d0(%rbp), %rsi
callq 0xa82a0
jmp 0xa8e85
leaq -0x1d0(%rbp), %rdi
callq 0x992c0
leaq -0x1d1(%rbp), %rdi
callq 0x994f0
movq $0x0, -0x8(%rbp)
jmp 0xa8edb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xa8ecd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x1d0(%rbp), %rdi
callq 0x992c0
leaq -0x1d1(%rbp), %rdi
callq 0x994f0
jmp 0xa8ee8
movq -0x8(%rbp), %rax
addq $0x230, %rsp            # imm = 0x230
popq %rbp
retq
movq -0x38(%rbp), %rdi
callq 0x99840
nopw %cs:(%rax,%rax)