// File: /workspace/github_c_makefile_star2_O0/orangeduck[P]mpc/tests/grammar.c
// Function: test_grammar
void test_grammar(void) {

  mpc_parser_t *Expr, *Prod, *Value, *Maths;
  mpc_ast_t *t0, *t1, *t2;
  
  Expr  = mpc_new("expression");
  Prod  = mpc_new("product");
  Value = mpc_new("value");
  Maths = mpc_new("maths");
  
  mpc_define(Expr,  mpca_grammar(MPCA_LANG_DEFAULT, " <product> (('+' | '-') <product>)* ", Prod));
  mpc_define(Prod,  mpca_grammar(MPCA_LANG_DEFAULT, " <value>   (('*' | '/')   <value>)* ", Value));
  mpc_define(Value, mpca_grammar(MPCA_LANG_DEFAULT, " /[0-9]+/ | '(' <expression> ')' ", Expr));
  mpc_define(Maths, mpca_total(Expr));
  
  t0 = mpc_ast_new("product|value|regex", "24");
  t1 = mpc_ast_build(1, "product|>",
    mpc_ast_build(3, "value|>",
      mpc_ast_new("char", "("),
      mpc_ast_new("expression|product|value|regex", "5"),
      mpc_ast_new("char", ")")));
  
  t2 = mpc_ast_build(3, ">",
      
      mpc_ast_build(3, "product|value|>",
        mpc_ast_new("char", "("),
        mpc_ast_build(3, "expression|>",
          
          mpc_ast_build(5, "product|>", 
            mpc_ast_new("value|regex", "4"),
            mpc_ast_new("char", "*"),
            mpc_ast_new("value|regex", "2"),
            mpc_ast_new("char", "*"),
            mpc_ast_new("value|regex", "11")),
            
          mpc_ast_new("char", "+"),
          mpc_ast_new("product|value|regex", "2")),
        mpc_ast_new("char", ")")),
      
      mpc_ast_new("char", "+"),
      mpc_ast_new("product|value|regex", "5"));
  
  PT_ASSERT(mpc_test_pass(Maths, "  24 ", t0, (int(*)(const void*,const void*))mpc_ast_eq, (mpc_dtor_t)mpc_ast_delete, (void(*)(const void*))mpc_ast_print));
  PT_ASSERT(mpc_test_pass(Maths, "(5)", t1, (int(*)(const void*,const void*))mpc_ast_eq, (mpc_dtor_t)mpc_ast_delete, (void(*)(const void*))mpc_ast_print));
  PT_ASSERT(mpc_test_pass(Maths, "(4 * 2 * 11 + 2) + 5", t2, (int(*)(const void*,const void*))mpc_ast_eq, (mpc_dtor_t)mpc_ast_delete, (void(*)(const void*))mpc_ast_print));
  PT_ASSERT(mpc_test_fail(Maths, "a", t0, (int(*)(const void*,const void*))mpc_ast_eq, (mpc_dtor_t)mpc_ast_delete, (void(*)(const void*))mpc_ast_print));
  PT_ASSERT(mpc_test_fail(Maths, "2b+4", t0, (int(*)(const void*,const void*))mpc_ast_eq, (mpc_dtor_t)mpc_ast_delete, (void(*)(const void*))mpc_ast_print));

  mpc_ast_delete(t0);
  mpc_ast_delete(t1);
  mpc_ast_delete(t2);
  
  mpc_cleanup(4, Expr, Prod, Value, Maths);
  
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
leaq 0x10c7c(%rip), %rdi     # 0x14bce
callq 0x9350
movq %rax, -0x8(%rbp)
leaq 0x10c77(%rip), %rdi     # 0x14bd9
callq 0x9350
movq %rax, -0x10(%rbp)
leaq 0x10c6f(%rip), %rdi     # 0x14be1
callq 0x9350
movq %rax, -0x18(%rbp)
leaq 0x10378(%rip), %rdi     # 0x142fa
callq 0x9350
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x10(%rbp), %rdx
xorl %edi, %edi
leaq 0x10c44(%rip), %rsi     # 0x14be7
movb $0x0, %al
callq 0xf7c0
movq -0xb8(%rbp), %rdi
movq %rax, %rsi
callq 0x9890
movq -0x10(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x18(%rbp), %rdx
xorl %edi, %edi
leaq 0x10c3b(%rip), %rsi     # 0x14c0c
movb $0x0, %al
callq 0xf7c0
movq -0xb0(%rbp), %rdi
movq %rax, %rsi
callq 0x9890
movq -0x18(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x8(%rbp), %rdx
xorl %edi, %edi
leaq 0x10c32(%rip), %rsi     # 0x14c31
movb $0x0, %al
callq 0xf7c0
movq -0xa8(%rbp), %rdi
movq %rax, %rsi
callq 0x9890
movq -0x20(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x8(%rbp), %rdi
callq 0xee60
movq -0xa0(%rbp), %rdi
movq %rax, %rsi
callq 0x9890
leaq 0x10c31(%rip), %rdi     # 0x14c70
leaq 0x10c0d(%rip), %rsi     # 0x14c53
callq 0xd8f0
movq %rax, -0x28(%rbp)
leaq 0x10c0a(%rip), %rdi     # 0x14c60
leaq 0x135fc(%rip), %rsi     # 0x17659
callq 0xd8f0
movq %rax, -0x98(%rbp)
leaq 0x10bf5(%rip), %rdi     # 0x14c65
leaq 0x10d74(%rip), %rsi     # 0x14deb
callq 0xd8f0
movq %rax, -0x90(%rbp)
leaq 0x10bd6(%rip), %rdi     # 0x14c60
leaq 0x12641(%rip), %rsi     # 0x166d2
callq 0xd8f0
movq -0x98(%rbp), %rdx
movq -0x90(%rbp), %rcx
movq %rax, %r8
movl $0x3, %edi
leaq 0x10bd9(%rip), %rsi     # 0x14c8c
movb $0x0, %al
callq 0xda00
movq %rax, %rdx
movl $0x1, %edi
leaq 0x10b8d(%rip), %rsi     # 0x14c56
movb $0x0, %al
callq 0xda00
movq %rax, -0x30(%rbp)
leaq 0x10b85(%rip), %rdi     # 0x14c60
leaq 0x13577(%rip), %rsi     # 0x17659
callq 0xd8f0
movq %rax, -0x58(%rbp)
leaq 0x10b86(%rip), %rdi     # 0x14c78
leaq 0x10346(%rip), %rsi     # 0x1443f
callq 0xd8f0
movq %rax, -0x88(%rbp)
leaq 0x10b54(%rip), %rdi     # 0x14c60
leaq 0x1280d(%rip), %rsi     # 0x16920
callq 0xd8f0
movq %rax, -0x80(%rbp)
leaq 0x10b55(%rip), %rdi     # 0x14c78
leaq 0x10490(%rip), %rsi     # 0x145ba
callq 0xd8f0
movq %rax, -0x78(%rbp)
leaq 0x10b26(%rip), %rdi     # 0x14c60
leaq 0x127df(%rip), %rsi     # 0x16920
callq 0xd8f0
movq %rax, -0x70(%rbp)
leaq 0x10b27(%rip), %rdi     # 0x14c78
leaq 0x10b49(%rip), %rsi     # 0x14ca1
callq 0xd8f0
movq -0x88(%rbp), %rdx
movq -0x80(%rbp), %rcx
movq -0x78(%rbp), %r8
movq -0x70(%rbp), %r9
movl $0x5, %edi
leaq 0x10ada(%rip), %rsi     # 0x14c56
movq %rax, (%rsp)
movb $0x0, %al
callq 0xda00
movq %rax, -0x68(%rbp)
leaq 0x10ace(%rip), %rdi     # 0x14c60
leaq 0x11fed(%rip), %rsi     # 0x16186
callq 0xd8f0
movq %rax, -0x60(%rbp)
leaq 0x10ac7(%rip), %rdi     # 0x14c70
leaq 0x1040a(%rip), %rsi     # 0x145ba
callq 0xd8f0
movq -0x68(%rbp), %rdx
movq -0x60(%rbp), %rcx
movq %rax, %r8
movl $0x3, %edi
leaq 0x10ac8(%rip), %rsi     # 0x14c94
movb $0x0, %al
callq 0xda00
movq %rax, -0x50(%rbp)
leaq 0x10a82(%rip), %rdi     # 0x14c60
leaq 0x124ed(%rip), %rsi     # 0x166d2
callq 0xd8f0
movq -0x58(%rbp), %rdx
movq -0x50(%rbp), %rcx
movq %rax, %r8
movl $0x3, %edi
leaq 0x10a83(%rip), %rsi     # 0x14c84
movb $0x0, %al
callq 0xda00
movq %rax, -0x48(%rbp)
leaq 0x10a4d(%rip), %rdi     # 0x14c60
leaq 0x11f6c(%rip), %rsi     # 0x16186
callq 0xd8f0
movq %rax, -0x40(%rbp)
leaq 0x10a46(%rip), %rdi     # 0x14c70
leaq 0x10bba(%rip), %rsi     # 0x14deb
callq 0xd8f0
movq -0x48(%rbp), %rdx
movq -0x40(%rbp), %rcx
movq %rax, %r8
movl $0x3, %edi
leaq 0x133dd(%rip), %rsi     # 0x1762a
movb $0x0, %al
callq 0xda00
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x10a3d(%rip), %rsi     # 0x14ca4
leaq 0x99c2(%rip), %rcx      # 0xdc30
leaq 0x95fb(%rip), %r8       # 0xd870
leaq 0x9d74(%rip), %r9       # 0xdff0
callq 0xd780
movl %eax, %edi
leaq 0x10a20(%rip), %rsi     # 0x14caa
leaq 0x10aa9(%rip), %rdx     # 0x14d3a
movl $0x2e, %ecx
callq 0x5780
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rdx
leaq 0x10094(%rip), %rsi     # 0x1433e
leaq 0x997f(%rip), %rcx      # 0xdc30
leaq 0x95b8(%rip), %r8       # 0xd870
leaq 0x9d31(%rip), %r9       # 0xdff0
callq 0xd780
movl %eax, %edi
leaq 0x10a7d(%rip), %rsi     # 0x14d4a
leaq 0x10a66(%rip), %rdx     # 0x14d3a
movl $0x2f, %ecx
callq 0x5780
movq -0x20(%rbp), %rdi
movq -0x38(%rbp), %rdx
leaq 0x10aeb(%rip), %rsi     # 0x14dd8
leaq 0x993c(%rip), %rcx      # 0xdc30
leaq 0x9575(%rip), %r8       # 0xd870
leaq 0x9cee(%rip), %r9       # 0xdff0
callq 0xd780
movl %eax, %edi
leaq 0x10add(%rip), %rsi     # 0x14ded
leaq 0x10a23(%rip), %rdx     # 0x14d3a
movl $0x30, %ecx
callq 0x5780
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x132c4(%rip), %rsi     # 0x175f4
leaq 0x98f9(%rip), %rcx      # 0xdc30
leaq 0x9532(%rip), %r8       # 0xd870
leaq 0x9cab(%rip), %r9       # 0xdff0
callq 0xd6f0
movl %eax, %edi
leaq 0x10b39(%rip), %rsi     # 0x14e8c
leaq 0x109e0(%rip), %rdx     # 0x14d3a
movl $0x31, %ecx
callq 0x5780
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x100c9(%rip), %rsi     # 0x1443c
leaq 0x98b6(%rip), %rcx      # 0xdc30
leaq 0x94ef(%rip), %r8       # 0xd870
leaq 0x9c68(%rip), %r9       # 0xdff0
callq 0xd6f0
movl %eax, %edi
leaq 0x10b82(%rip), %rsi     # 0x14f18
leaq 0x1099d(%rip), %rdx     # 0x14d3a
movl $0x32, %ecx
callq 0x5780
movq -0x28(%rbp), %rdi
callq 0xd870
movq -0x30(%rbp), %rdi
callq 0xd870
movq -0x38(%rbp), %rdi
callq 0xd870
movq -0x8(%rbp), %rsi
movq -0x10(%rbp), %rdx
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %r8
movl $0x4, %edi
movb $0x0, %al
callq 0x9a50
addq $0xc0, %rsp
popq %rbp
retq
nopw (%rax,%rax)