STATIC int readtoken(void) { int t; int savecheckkwd = checkkwd; struct alias *ap; #if DEBUG int alreadyseen = tokpushback; #endif top: t = xxreadtoken(); if (checkkwd) { /* * eat newlines */ if (checkkwd == 2) { checkkwd = 0; while (t == TNL) { parseheredoc(); t = xxreadtoken(); } } else checkkwd = 0; /* * check for keywords and aliases */ if (t == TWORD && !quoteflag) { const char * const *pp; for (pp = parsekwd; *pp; pp++) { if (**pp == *wordtext && equal(*pp, wordtext)) { lasttoken = t = pp - parsekwd + KWDOFFSET; TRACE(("keyword %s recognized\n", tokname[t])); goto out; } } if (noaliases == 0 && (ap = lookupalias(wordtext, 1)) != NULL) { pushstring(ap->val, strlen(ap->val), ap); checkkwd = savecheckkwd; goto top; } } out: checkkwd = (t == TNOT) ? savecheckkwd : 0; } #if DEBUG if (!alreadyseen) TRACE(("token %s %s\n", tokname[t], t == TWORD ? wordtext : "")); else TRACE(("reread token %s %s\n", tokname[t], t == TWORD ? wordtext : "")); #endif return (t); }
STATIC int readtoken() { int t; if (tokpushback) { return xxreadtoken(); } else { t = xxreadtoken(); /* TRACE(("token %s\n", tokname[t])); */ return t; } }