2 * DEBUG_LEX.C - Rune Language Lexer debug routines
4 * (c)Copyright 1993-2014, Matthew Dillon, All Rights Reserved. See the
5 * COPYRIGHT file at the base of the distribution.
11 LexDebugLine(token_t *tok)
13 Lex *lex = tok->t_Lex;
15 int boff = tok->t_Ptr - lex->l_Base;
16 int eoff = boff + tok->t_Len;
18 lexUpdateCache(lex, boff);
20 printf("%08x", tok->t_Type);
21 if (tok->t_Type & TOKF_ERROR)
22 printf(" (%s)\n\t", LexErrStr(tok));
24 fwrite(lex->l_Base + lex->l_CacheOff,
25 1, boff - lex->l_CacheOff, stdout);
26 fprintf(stdout, "\033[7m");
27 fwrite(lex->l_Base + boff, 1, eoff - boff, stdout);
28 fprintf(stdout, "\033[m");
29 for (len = eoff; len < lex->l_Bytes && lex->l_Base[len] != '\n'; ++len)
31 fwrite(lex->l_Base + eoff, 1, len - eoff, stdout);
32 fprintf(stdout, "\n");