@@ -181,6 +181,7 @@ const Token* Parser::parseFile(const Token* pNext)
181181 break ;
182182 case IdentifierToken::KW_STRUCT :
183183 case IdentifierToken::KW_CLASS :
184+ case IdentifierToken::KW_UNION :
184185 pNext = parseClass (pNext);
185186 break ;
186187 case IdentifierToken::KW_TEMPLATE :
@@ -228,6 +229,7 @@ const Token* Parser::parseNameSpace(const Token* pNext)
228229 break ;
229230 case IdentifierToken::KW_STRUCT :
230231 case IdentifierToken::KW_CLASS :
232+ case IdentifierToken::KW_UNION :
231233 pNext = parseClass (pNext);
232234 break ;
233235 case IdentifierToken::KW_TEMPLATE :
@@ -264,7 +266,7 @@ const Token* Parser::parseClass(const Token* pNext)
264266
265267const Token* Parser::parseClass (const Token* pNext, std::string& decl)
266268{
267- poco_assert (isKeyword (pNext, IdentifierToken::KW_CLASS ) || isKeyword (pNext, IdentifierToken::KW_STRUCT ));
269+ poco_assert (isKeyword (pNext, IdentifierToken::KW_CLASS ) || isKeyword (pNext, IdentifierToken::KW_STRUCT ) || isKeyword (pNext, IdentifierToken:: KW_UNION ) );
268270
269271 _pCurrentSymbol = 0 ;
270272 bool isClass = isKeyword (pNext, IdentifierToken::KW_CLASS );
@@ -384,6 +386,7 @@ const Token* Parser::parseClassMembers(const Token* pNext, Struct* pClass)
384386 break ;
385387 case IdentifierToken::KW_STRUCT :
386388 case IdentifierToken::KW_CLASS :
389+ case IdentifierToken::KW_UNION :
387390 pNext = parseClass (pNext);
388391 break ;
389392 case IdentifierToken::KW_TEMPLATE :
@@ -436,7 +439,7 @@ const Token* Parser::parseTemplate(const Token* pNext)
436439 pNext = next ();
437440 expectOperator (pNext, OperatorToken::OP_LT , " <" );
438441 pNext = parseTemplateArgs (pNext, decl);
439- if (isKeyword (pNext, IdentifierToken::KW_CLASS ) || isKeyword (pNext, IdentifierToken::KW_STRUCT ))
442+ if (isKeyword (pNext, IdentifierToken::KW_CLASS ) || isKeyword (pNext, IdentifierToken::KW_STRUCT ) || isKeyword (pNext, IdentifierToken:: KW_UNION ) )
440443 return parseClass (pNext, decl);
441444 else
442445 return parseVarFunc (pNext, decl);
@@ -649,6 +652,10 @@ const Token* Parser::parseFunc(const Token* pNext, std::string& decl)
649652 if (pFunc) pFunc->makeFinal ();
650653 pNext = next ();
651654 }
655+ else if (isKeyword (pNext, IdentifierToken::KW_TRY ))
656+ {
657+ break ; // handled below
658+ }
652659 }
653660 if (isOperator (pNext, OperatorToken::OP_ASSIGN ))
654661 {
@@ -674,6 +681,32 @@ const Token* Parser::parseFunc(const Token* pNext, std::string& decl)
674681 if (pFunc)
675682 pFunc->makeInline ();
676683 }
684+ else if (isKeyword (pNext, IdentifierToken::KW_TRY ))
685+ {
686+ pNext = next ();
687+ if (isOperator (pNext, OperatorToken::OP_OPENBRACE ) || isOperator (pNext, OperatorToken::OP_COLON ))
688+ {
689+ while (!isOperator (pNext, OperatorToken::OP_OPENBRACE ) && !isEOF (pNext))
690+ pNext = next ();
691+
692+ pNext = parseBlock (pNext);
693+
694+ if (isKeyword (pNext, IdentifierToken::KW_CATCH ))
695+ {
696+ while (!isOperator (pNext, OperatorToken::OP_OPENBRACE ) && !isEOF (pNext))
697+ pNext = next ();
698+
699+ pNext = parseBlock (pNext);
700+ }
701+ else syntaxError (" expected catch block" );
702+
703+ if (!pFunc)
704+ pFunc = dynamic_cast <Function*>(currentNameSpace ()->lookup (name));
705+ if (pFunc)
706+ pFunc->makeInline ();
707+ }
708+ else syntaxError (" expected member initialization or block" );
709+ }
677710 else
678711 {
679712 expectOperator (pNext, OperatorToken::OP_SEMICOLON , " ;" );
0 commit comments