This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [PATCH] Handle comments in the C expression parser
- To: Michael Elizabeth Chastain <chastain at cygnus dot com>
- Subject: Re: [PATCH] Handle comments in the C expression parser
- From: Daniel Berlin <dberlin at redhat dot com>
- Date: 14 Feb 2001 00:29:46 -0500
- Cc: gdb-patches at sources dot redhat dot com
- References: <200102140501.VAA27824@bosch.cygnus.com>
Michael Elizabeth Chastain <chastain@cygnus.com> writes:
> Hi Daniel,
>
> ! while (*lexptr != '*')
> ! lexptr++;
>
> What happens if the user opens a comment with '/*' and does not close it?
> It looks like lexptr will go off into the weeds.
Yes, I assumed they would close it.
I'll fix it.
it's a simple fix anyway, i'd rather someone review the patch assuming
that bug will be fixed (change it to while (*lexptr && *lexptr !=
'*')).
>
> Also I do not know if lexptr has access to the whole input in contiguous
> memory, or if it gets fed chunks of characters as they arrive.
It has to, it's the lexer. It's doing the tokenizing.
The parser will see and exp, then ask for the next token. We only say
"/" if it's not a /*. Otherwise, we say it's the first thing after the
comment.
That was the only use of "/" in the entire parser, (exp '/' exp). So
this is safe.
> I can do stuff like this in gdb:
>
> (gdb) print 1 + \
> 2
> $1 = 3
>
(gdb) print 1 + \
/* this is a test */ \
3
$1 = 4
(gdb)
(gdb) print 1 + \
/* this is \
a test \
of \
comments \
*/ 3
$2 = 4
(gdb)
:)
Push up, after typing that in, and see what your line got transformed into.
> On the design level, I am not opposed to adding in C style comments
> in a C parser. But I am skeptical about the planned use for:
>
> break 'Foo::Foo /* base */ (int)'
>
> ... which is what I presume you are working towards.
Not in particular, I added it when someone suggested that, and wanted
to get it into the tree before it became a casualty of bitrot on one
of my trees, like the ternary search tree stuff i have that helps
demangled minsym lookups, and demangled name lookups, and memory
usage, a *ton*.
:)