[QUERY] C++ ambiguties -- is this right?

jlilley@empathy.com (John Lilley)
7 Jan 1997 12:18:37 -0500

          From comp.compilers

Related articles
[QUERY] C++ ambiguties -- is this right? jlilley@empathy.com (1997-01-07)
| List of all articles for this month |
From: jlilley@empathy.com (John Lilley)
Newsgroups: comp.std.c++,comp.compilers
Date: 7 Jan 1997 12:18:37 -0500
Organization: Nerds for Hire, Inc.
Keywords: C++, parse, question

I have a question concering the dreaded declaration/expression
ambiguities in C++. This is how my C++ parser treats the cases
described below. Am I handling this right?


Context: this is in a code block where statements are parsed.
Assuming that declarations with no declaration-specifiers are allowed,
then I parse this:


        g(int(x), int(y)), h(int(z), int(3));


as declaring g as a function, and h as a variable with (too many)
initializers. This bothers me -- since it is not valid to declare
variables with no declaration-specifiers, then should this
interpretation be rejected in favor of a comma-expression calling g()
and h()?


This one:


        g(int(x), int(y)), h(int(z), int(3)), 5;


I parse as a comma-expression calling g() and h() and finally yielding
5.


I'm unclear as to the status of declarations with no
declaration-specifiers. Are they still allowed in the latest draft?
Even if they are disallowed, is this sort of stuff still a practical
consideration for C++ parser wishing to handle old-style function
declarations?


thanks,
john lilley
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.