/* * DEBUG_LEX.C - Rune Language Lexer debug routines * * (c)Copyright 1993-2014, Matthew Dillon, All Rights Reserved. See the * COPYRIGHT file at the base of the distribution. */ #include "defs.h" void LexDebugLine(token_t *tok) { Lex *lex = tok->t_Lex; int len; int boff = tok->t_Ptr - lex->l_Base; int eoff = boff + tok->t_Len; lexUpdateCache(lex, boff); printf("%08x", tok->t_Type); if (tok->t_Type & TOKF_ERROR) printf(" (%s)\n\t", LexErrStr(tok)); printf(" "); fwrite(lex->l_Base + lex->l_CacheOff, 1, boff - lex->l_CacheOff, stdout); fprintf(stdout, "\033[7m"); fwrite(lex->l_Base + boff, 1, eoff - boff, stdout); fprintf(stdout, "\033[m"); for (len = eoff; len < lex->l_Bytes && lex->l_Base[len] != '\n'; ++len) ; fwrite(lex->l_Base + eoff, 1, len - eoff, stdout); fprintf(stdout, "\n"); }