Debug Trace Mode in (YACC & BISON) and (Lex & Flex)

peteolcott <>
Thu, 15 Jun 2017 15:30:22 -0700 (PDT)

          From comp.compilers

Related articles
Debug Trace Mode in (YACC & BISON) and (Lex & Flex) (peteolcott) (2017-06-15)
| List of all articles for this month |

From: peteolcott <>
Newsgroups: comp.compilers
Date: Thu, 15 Jun 2017 15:30:22 -0700 (PDT)
Organization: Compilers Central
Injection-Info:; posting-host=""; logging-data="8843"; mail-complaints-to=""
Keywords: yacc, lex, debug, comment
Posted-Date: 15 Jun 2017 18:51:06 EDT

lex & yacc by Levine, Mason & Brown very clearly and concisely explain the minimal required steps to invoke YACC/BISON Debug Trace Mode:

YYDEBUG must be defined in the declaration section of the "Y" file:
#define YYDEBUG 1

yydebug must be initialized in the main() of the "Y" file:
yydebug = 1;

BISON documentation clearly explains what YACC / BISON debug trace mode does:

(1) Each time the parser calls yylex, what kind of token was read.

(2) Each time a token is shifted, the depth and complete contents
        of the state stack (see Parser States).

(3) Each time a rule is reduced, which rule it is, and the complete
        contents of the state stack afterward.

This feature has worked since the 1.25 (1995) through the current 3.0.4 (2016) versions of Bison.

Flex only requires a comment line option of -d or --debug.
The -d option is supposed to also work with Lex.

This produces a list of each matched token and the corresponding "L" file line number where the match occurred.
[Uh, yes. Was there a question? -John]

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.