[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Debugging "$4"
From: |
Maury Markowitz |
Subject: |
Re: Debugging "$4" |
Date: |
Thu, 8 Oct 2020 09:42:01 -0400 |
> On Oct 8, 2020, at 2:17 AM, Akim Demaille <akim@lrde.epita.fr> wrote:
> Chris might be very right here. Maury, have you looked at your debug traces?
>
> https://www.gnu.org/software/bison/manual/html_node/Tracing.html
I turned on YYDEBUG (my duh) and it appears the parse is working as expected?
Recall the line is:
200 IF 1=1 THEN PRINT"3":PRINT"4"
Relevant bits... Its parsed the "IF 1=1 THEN" part and notices the PRINT:
Shifting token THEN ()
Entering state 122
Reading a token: Next token is token PRINT ()
Then after many rules fire on the the PRINT it gets:
Next token is token ':' ()
Many more roles fire as a result, unwinding the stack and producing:
Reducing stack by rule 26 (line 364):
$1 = token PRINT ()
$2 = nterm printlist ()
-> $$ = nterm statement ()
So the first PRINT is now turned into a statement, as expected. Then it
continues:
Shifting token ':' ()
Entering state 92
Reading a token: Next token is token PRINT ()
A similar set of rules to the first print fires and ends here:
Reducing stack by rule 26 (line 364):
$1 = token PRINT ()
$2 = nterm printlist ()
-> $$ = nterm statement ()
The second print is also a statement now. The line is now complete and it reads
the \n, so it unwinds the rest:
Reducing stack by rule 8 (line 179):
$1 = nterm statement ()
$2 = token ':' ()
$3 = nterm statements ()
-> $$ = nterm statements ()
To me it *appears* that it has successfully fired the "statements" rule?
Continues...
Reducing stack by rule 21 (line 315):
$1 = token IF ()
$2 = nterm expression ()
$3 = token THEN ()
$4 = nterm statements ()
-> $$ = nterm statement ()
That all looks correct to me, but I am noob.
I made a fatal mistake basing this on g_list, which uses a (void *) to the
"data" (my statement_t) and thus debugging the C side is a PITA.
Re: Debugging "$4", Hans Åberg, 2020/10/08