aboutsummaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authorGravatar zinc <zinc@downsta.ir> 2026-10-14 16:25:31 +0330
committerGravatar zinc <zinc@downsta.ir> 2026-10-14 16:25:31 +0330
commit87dba496160abf20557dbf102b7bc9ce4078c0d9 (patch)
treebf046fdc9d28d3d974969f0581e4fcab03477619 /src/tools
parentMerge branch 'main' into work/spec (diff)
Revert "zc0: u*x, m*x, d*x are products when u, m or d is a visible local or global (spec 1.6.3)"
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/zc0.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/tools/zc0.c b/src/tools/zc0.c
index 81561ce..2261661 100644
--- a/src/tools/zc0.c
+++ b/src/tools/zc0.c
@@ -238,8 +238,12 @@ static int accept(const char *s) { if (is(s)) { next(); return 1; } return 0; }
static void expect(const char *s) { if (!accept(s)) { char b[64]; sprintf(b, "expected '%s'", s); die(b); } }
static char *ident(void) { static char b[8][256]; static int k; char *r = b[k++ & 7]; if (tk != T_ID) die("expected a name"); strcpy(r, ts); next(); return r; }
/* u, m and d are ordinary names. u*x, m*x and d*x are recasts when the star touches
- the letter and no variable of that name is visible, which the raw character after the name tells: u * x is a product, and
+ the letter, which the raw character after the name tells: u * x is a product, and
so is u*=x. the current token is the name, so pos is just past it. */
+static int isrecast(void)
+{
+ return tk == T_ID && ts[1] == 0 && (ts[0] == 'u' || ts[0] == 'm' || ts[0] == 'd') && src[pos] == '*' && src[pos + 1] != '=';
+}
/* ---- symbols ---- */
typedef struct { char name[64]; int kind, sig, defd, str; int64_t val; } Sym; /* str: a global holding a byte string, or a function returning one */
@@ -280,13 +284,6 @@ static void fnref(const char *n) /* push a function address, fixing it up later
typedef struct { char name[64]; int slot, arr, flt, str, dstr; } Loc; /* dstr: declared bstr, so always a byte string */
static Loc lo[1024]; static int nlo, nslot, infn;
static Loc *findl(const char *n) { int i; for (i = nlo; i--;) if (!strcmp(lo[i].name, n)) return &lo[i]; return 0; }
-static int isrecast(void)
-{
- Sym *g;
- if (!(tk == T_ID && ts[1] == 0 && (ts[0] == 'u' || ts[0] == 'm' || ts[0] == 'd') && src[pos] == '*' && src[pos + 1] != '=')) return 0;
- if (findl(ts)) return 0; /* a visible variable named u, m or d: a product (spec 1.6.3) */
- g = find(ts); return !(g && (g->kind == K_GVAR || g->kind == K_GARR));
-}
static void laddr(int k) { lit(ZFP); op(O_LD); if (k) { lit(k); op(O_ADD); } }
/* ---- operator tables ---- */