Rune - Change regsave burden for syscalls
[rune.git] / librune / debug_lex.c
1 /*
2  * DEBUG_LEX.C  - Rune Language Lexer debug routines
3  *
4  * (c)Copyright 1993-2014, Matthew Dillon, All Rights Reserved.  See the  
5  *    COPYRIGHT file at the base of the distribution.
6  */
7
8 #include "defs.h"
9
10 void
11 LexDebugLine(token_t *tok)
12 {
13         Lex *lex = tok->t_Lex;
14         int len;
15         int boff = tok->t_Ptr - lex->l_Base;
16         int eoff = boff + tok->t_Len;
17
18         lexUpdateCache(lex, boff);
19
20         printf("%08x", tok->t_Type);
21         if (tok->t_Type & TOKF_ERROR)
22                 printf(" (%s)\n\t", LexErrStr(tok));
23         printf(" ");
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)
30                 ;
31         fwrite(lex->l_Base + eoff, 1, len - eoff, stdout);
32         fprintf(stdout, "\n");
33 }