[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Question about token stack
From: |
Ervin Hegedüs |
Subject: |
Re: Question about token stack |
Date: |
Sun, 30 Aug 2020 17:17:47 +0200 |
User-agent: |
NeoMutt/20171215 |
Hi Akim,
thanks again.
On Sun, Aug 30, 2020 at 05:04:50PM +0200, Akim Demaille wrote:
>
>
> > Le 30 août 2020 à 16:36, Ervin Hegedüs <airween@gmail.com> a écrit :
> >
> > %destructor { printf("free() called\n"); free ($$); } <*>
> >
> > but it never called, and valgrind still shows that the block is
> > still reachable.
>
> You should add debug traces and study them. Pay special attention
> to the error recovery sequence.
>
> > Btw I reviewed the generated code, but I'm afriad this destructor
> > called only when the parser run into the error state.
>
> Yes, that's what the doc says, and that is what I believed is
> what you are trying to address.
yes, now I think too it's enough.
> > Now I thought what happens if the scanner found an unrecognized
> > token after the previous was pushed into stack - that item is
> > sill at there. So I'm still curious, how can I clear the whole
> > stack.
>
> Since you don't have error-recovery, your stack will be cleared.
> Show us your debug traces (yydebug = 1).
in my parser code I got:
#ifdef YYDEBUG
yydebug = 1;
#endif
and I compiled the code:
bison -d myparser.y
flex -d mylexer.l
gcc ...
the output is:
--accepting rule at line 52 ("ConfKey2")
--accepting rule at line 67 (" ")
--accepting rule at line 55 ("fo")
This is a configuration directive and argument: 'ConfKey2' 'fo'
--accepting rule at line 68 ("'")
UNKNOWN TOKEN: ''' in file: badconf3.conf, line 1, state: ST_CONFIG_DIRECTIVE
--accepting rule at line 55 ("o")
Parse error: syntax error in file , line 1
In this case the problem is the configuration argument contains a
' (single-quoted mark):
ConfKey2 fo'o
So many thanks! :)
a.
ps: I've added an own implelemtation. I stored all address of
symbols which pushed to stack, and in yyerror() I iterate that
list and freed all address. This is just a workaround, but I got
what I expected. But then I saw in case of error (it doesn't
matter where error occurred) only one item on the stack.
- Question about token stack, Ervin Hegedüs, 2020/08/30
- Re: Question about token stack, Akim Demaille, 2020/08/30
- Re: Question about token stack, Ervin Hegedüs, 2020/08/30
- Re: Question about token stack, Akim Demaille, 2020/08/30
- Re: Question about token stack,
Ervin Hegedüs <=
- Re: Question about token stack, Akim Demaille, 2020/08/30
- Re: Question about token stack, Ervin Hegedüs, 2020/08/30
- Re: Question about token stack, Akim Demaille, 2020/08/30
- Re: Question about token stack, Hegedüs Ervin, 2020/08/30