From 493ee2241e4f16b196bbe320bba997c9c3df081d Mon Sep 17 00:00:00 2001 From: dsmith Date: Thu, 13 Jul 2006 20:41:00 +0000 Subject: 2006-07-13 David Smith * parse.cxx (parser::expect_unknown2): New function that looks for 2 possible token types. * parse.cxx (parser::expect_ident_or_keyword): New function that calls parser::expect_unknown2. * parse.cxx (parser::parse_symbol): Calls parser::expect_ident_or_keyword to allow keywords to appear when expanding target symbols (Bugzilla #2913). * parse.h: Added prototypes for parser::expect_unknown2 and parser::expect_ident_or_keyword. * testsuite/parseok/seventeen.stp: New test to check for allowing keywords when expanding target symbols. --- parse.cxx | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'parse.cxx') diff --git a/parse.cxx b/parse.cxx index 6a565cf4..76c1003f 100644 --- a/parse.cxx +++ b/parse.cxx @@ -374,6 +374,17 @@ parser::expect_unknown (token_type tt, string & target) } +const token* +parser::expect_unknown2 (token_type tt1, token_type tt2, string & target) +{ + const token *t = next(); + if (!(t && (t->type == tt1 || t->type == tt2))) + throw parse_error ("expected " + tt2str(tt1) + " or " + tt2str(tt2)); + target = t->content; + return t; +} + + const token* parser::expect_op (std::string const & expected) { @@ -405,6 +416,13 @@ parser::expect_ident (std::string & target) } +const token* +parser::expect_ident_or_keyword (std::string & target) +{ + return expect_unknown2 (tok_identifier, tok_keyword, target); +} + + bool parser::peek_op (std::string const & op) { @@ -2172,7 +2190,7 @@ parser::parse_symbol () if (peek_op ("->")) { next(); - expect_ident (c); + expect_ident_or_keyword (c); tsym->components.push_back (make_pair (target_symbol::comp_struct_member, c)); } -- cgit