calc

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

commit f27fed812adde821982feb1215fda152bcecfae0
parent 4d9cd52803441623a53f43f82d88687dbb9c4172
Author: amin <dev@aminmesbah.com>
Date:   Mon,  1 Jan 2024 02:46:30 +0000

Get calc building under clang-cl on windows

FossilOrigin-Name: baa93308270bbfeb6fd780944e44232899de843a16f7fa09a12c3501a7404aab
Diffstat:
Mcalc.c | 11++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/calc.c b/calc.c @@ -33,7 +33,7 @@ void *crealloc(void *ptr, size_t num_bytes) { return ptr; } -#define buf__hdr(b) ((struct BufHdr *)((uint8_t *)(b) - offsetof(struct BufHdr, buf))) +#define buf__hdr(b) ((struct BufHdr *)(void *)((uint8_t *)(b) - offsetof(struct BufHdr, buf))) #define buf_cap(b) ((b) ? buf__hdr(b)->cap : 0) #define buf_len(b) ((b) ? buf__hdr(b)->len : 0) @@ -88,7 +88,7 @@ void buf_test(void) { X(TOKEN_PAREN_R, ")") \ X(TOKEN_INT, "") \ \ - X(_TOKEN_KIND_COUNT, "") + X(TOKEN__KIND_COUNT, "") enum TokenKind { #define X(kind, glyph) kind, @@ -112,13 +112,13 @@ char *TokenKindGlyphs[] = { char *token_kind_glyph(enum TokenKind k) { assert(k >= TOKEN_NONE && k < TOKEN_INT); - assert(k <= (sizeof TokenKindNames / sizeof TokenKindGlyphs[0])); + assert((size_t)k <= (sizeof TokenKindGlyphs / sizeof TokenKindGlyphs[0])); return TokenKindGlyphs[k]; } char *token_kind_name(enum TokenKind k) { - assert(k >= TOKEN_NONE && k < _TOKEN_KIND_COUNT); - assert(k <= (sizeof TokenKindNames / sizeof TokenKindNames[0])); + assert(k >= TOKEN_NONE && k < TOKEN__KIND_COUNT); + assert((size_t)k <= (sizeof TokenKindNames / sizeof TokenKindNames[0])); return TokenKindNames[k]; } @@ -475,6 +475,7 @@ int32_t eval_expr(Expr *e) { ERROR(); break; } + return 0; } // Precedence Climbing