This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [PATCH] Handle comments in the C expression parser


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*.

:)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]