// File: /workspace/github_c_makefile_star2_O0/MaoKo[P]FGFX/fgfp/src/cfg.c
// Function: cfg_precedence_atom
static int
cfg_precedence_atom(cfg_t* cfg, size_t kind_prec, size_t prec_depth) {
	size_t allow_kind = peek_token(cfg->lex);

	if ((allow_kind != T_TERMINAL) && (allow_kind != T_LITERAL)) {
		errorf(CURRENT_LINE(cfg->lex),
						"Missing a token identifier or a literal.");
		return (ERROR);
	}

	while ((allow_kind == T_TERMINAL) || (allow_kind == T_LITERAL)) {
		advance_token(cfg->lex);
		symbol_t* prec_ter = add_symbol_cfg(cfg, allow_kind,
													C_LEXEME(cfg->lex));
		if (prec_ter->prec) {
			errorf(CURRENT_LINE(cfg->lex),
							"Precedence already define for the symbol %s.",
							prec_ter->name);
			return (ERROR);
		}

		precedence_t* prec = NEW(precedence_t, 1);
		if (!prec)
			{ return (ERROR); }

		memset(prec, 0, sizeof(*prec));
		prec->precedence = prec_depth;

		switch (kind_prec) {
			case T_LEFT: prec->left = true; break;
			case T_RIGHT: prec->right = true; break;
			case T_NONASSOC:
					prec->right = true;
					prec->left = true;
					break;
		}

		prec_ter->prec = prec;
		if (peek_token(cfg->lex) != T_COMMA
								&& peek_token(cfg->lex) != T_RPAREN) {
			errorf(CURRENT_LINE(cfg->lex),
						"Missing a close paren in the $PRECEDENCE section.");
			return (ERROR);
		}
		else if (peek_token(cfg->lex) == T_COMMA)
			{ advance_token(cfg->lex); }

		allow_kind = peek_token(cfg->lex);
	}

	advance_token(cfg->lex);
	return (DONE);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x32e0
cltq
movq %rax, -0x28(%rbp)
cmpq $0x2d, -0x28(%rbp)
je 0x660b
cmpq $0x28, -0x28(%rbp)
je 0x660b
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movslq 0x28(%rax), %rdi
leaq 0x6376(%rip), %rsi      # 0xc96e
movb $0x0, %al
callq 0x4210
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x67b9
jmp 0x660d
movb $0x1, %al
cmpq $0x2d, -0x28(%rbp)
movb %al, -0x39(%rbp)
je 0x6624
cmpq $0x28, -0x28(%rbp)
sete %al
movb %al, -0x39(%rbp)
movb -0x39(%rbp), %al
testb $0x1, %al
jne 0x6630
jmp 0x67a5
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x2ca0
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rax
movl %eax, %esi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x10(%rax), %rax
movq (%rax), %rdx
callq 0x4b70
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x6698
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movslq 0x28(%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rdx
leaq 0x6312(%rip), %rsi      # 0xc997
movb $0x0, %al
callq 0x4210
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x67b9
movl $0x8, %edi
callq 0x38b0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x66b9
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x67b9
movq -0x38(%rbp), %rax
movq $0x0, (%rax)
movl -0x20(%rbp), %ecx
movq -0x38(%rbp), %rax
movl %ecx, (%rax)
movq -0x18(%rbp), %rax
movq %rax, -0x48(%rbp)
subq $0x6c, %rax
je 0x66f5
jmp 0x66dd
movq -0x48(%rbp), %rax
subq $0x6d, %rax
je 0x66ff
jmp 0x66e9
movq -0x48(%rbp), %rax
subq $0x6e, %rax
je 0x6709
jmp 0x6719
movq -0x38(%rbp), %rax
movb $0x1, 0x4(%rax)
jmp 0x6719
movq -0x38(%rbp), %rax
movb $0x1, 0x5(%rax)
jmp 0x6719
movq -0x38(%rbp), %rax
movb $0x1, 0x5(%rax)
movq -0x38(%rbp), %rax
movb $0x1, 0x4(%rax)
movq -0x38(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x32e0
cmpl $0x31, %eax
je 0x676c
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x32e0
cmpl $0x35, %eax
je 0x676c
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movslq 0x28(%rax), %rdi
leaq 0x6268(%rip), %rsi      # 0xc9c4
movb $0x0, %al
callq 0x4210
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x67b9
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x32e0
cmpl $0x31, %eax
jne 0x678b
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x2ca0
jmp 0x678d
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x32e0
cltq
movq %rax, -0x28(%rbp)
jmp 0x660d
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x2ca0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)