Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.compilers > #1894

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

From peteolcott <peterolcott2@gmail.com>
Newsgroups comp.compilers
Subject Debug Trace Mode in (YACC & BISON) and (Lex & Flex)
Date 2017-06-15 15:30 -0700
Organization Compilers Central
Message-ID <17-06-013@comp.compilers> (permalink)

Show all headers | View raw


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:

YACC or BISON DEBUG TRACE PROVIDES:
(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]

Back to comp.compilers | Previous | Next | Find similar | Unroll thread


Thread

Debug Trace Mode in (YACC & BISON) and (Lex & Flex) peteolcott <peterolcott2@gmail.com> - 2017-06-15 15:30 -0700

csiph-web