calc

Simple math expression parser.
git clone git://git.amin.space/calc.git
Log | Files | Refs | LICENSE

commit 76d328f0f74b05760e74063942c95d2a847c2626
parent 3c99feab11f34771533a26f7ed325eb0905a19df
Author: amin <dev@aminmesbah.com>
Date:   Sun, 25 Jul 2021 22:14:45 +0000

Clean up a few things

FossilOrigin-Name: 56448ad3b549f76e7bf001a6073ba2b93973eeb63661359e419dd16515d82b07
Diffstat:
Mcalc.c | 8++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/calc.c b/calc.c @@ -18,7 +18,7 @@ struct BufHdr { void *cmalloc(size_t num_bytes) { void *ptr = malloc(num_bytes); if (!ptr) { - fprintf(stderr, "crealloc failed\n"); + fprintf(stderr, "cmalloc failed\n"); exit(1); } return ptr; @@ -477,13 +477,13 @@ int32_t eval_expr(Expr *e) { } } -// precedence climbing +// Precedence Climbing // op_unary = "-" | "~". // op_mul = "*" | "/" | "%" | "<<" | ">>" | "&". // op_add = "+" | "-" | "|" | "^". // expr_operand = number. -// expr_grouping = "(" expr ")" -// expr_unary = ([op_unary] exp_unary) | exp_base. +// expr_grouping = "(" expr ") | expr_operand." +// expr_unary = ([op_unary] expr_unary) | expr_grouping. // expr_mul = expr_unary {op_mul expr_unary}. // expr_add = expr_mul {op_add expr_mul}. // expr = expr_add.