|C++ Template implementation email@example.com (Bill Fahle) (1998-04-21)|
|Re: C++ Template implementation firstname.lastname@example.org (Jerry Leichter) (1998-04-27)|
|Re: C++ Template implementation email@example.com (John Williams) (1998-04-27)|
|From:||"Bill Fahle" <firstname.lastname@example.org>|
|Date:||21 Apr 1998 00:40:24 -0400|
I have a working C parser that I am currently turning into a C++ parser. I
use the Roskind grammar for C, and have an old Roskind C++ grammar that
doesn't include templates or namespaces. What I'm wondering is how to
implement templates in the grammar without causing too many conflicts.
Something I've seen in several C++ grammars is the following:
template_class_name::= template_name "<" List(template_arg) ">".
template_arg::= expression | type_name.
What I'm wondering is
a) Why is template_class_name never used anywhere else in the grammar?
Is it just coerced by the parser into a typedefname when the
template_class_name is reduced, something like the lexer hack? If so,
what state does the parser enter at that point, and what happens to
the state stack? (This is different from the lexer hack because it is
a complete nonterminal tree being turned into a typedefname, not just
b) Why are expressions necessary to the template_arg? I've never seen
this in practice, and I'm not sure of the semantics. These seem to
cause a lot of the conflicts I experience, because of the >
ambiguity. A general expression would indeed be ambiguous:
SpecificList<Specific *, a>b > m_specificList;
Return to the
Search the comp.compilers archives again.