summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Slice/Grammar.y81
-rw-r--r--cpp/src/Slice/Parser.cpp29
-rw-r--r--cpp/src/slice2docbook/Gen.cpp18
3 files changed, 85 insertions, 43 deletions
diff --git a/cpp/src/Slice/Grammar.y b/cpp/src/Slice/Grammar.y
index dcefff20bf4..361d097b238 100644
--- a/cpp/src/Slice/Grammar.y
+++ b/cpp/src/Slice/Grammar.y
@@ -191,37 +191,39 @@ interface_export
// ----------------------------------------------------------------------
exception_decl
// ----------------------------------------------------------------------
-: ICE_EXCEPTION ICE_IDENTIFIER
+: local ICE_EXCEPTION ICE_IDENTIFIER
{
- unit->error("exceptions can not be forward declared");
+ unit->error("exceptions cannot be forward declared");
}
-| ICE_EXCEPTION keyword
+| local ICE_EXCEPTION keyword
{
- unit->error("keyword can not be used as exception name");
+ unit->error("keyword cannot be used as exception name");
}
;
// ----------------------------------------------------------------------
exception_def
// ----------------------------------------------------------------------
-: ICE_EXCEPTION ICE_IDENTIFIER
+: local ICE_EXCEPTION ICE_IDENTIFIER exception_extends
{
- StringTokPtr ident = StringTokPtr::dynamicCast($2);
+ BoolTokPtr local = BoolTokPtr::dynamicCast($1);
+ StringTokPtr ident = StringTokPtr::dynamicCast($3);
+ ExceptionPtr base = ExceptionPtr::dynamicCast($4);
ContainerPtr cont = unit->currentContainer();
- ExceptionPtr st = cont->createException(ident->v);
- if (!st)
+ ExceptionPtr ex = cont->createException(ident->v, local->v, base);
+ if (!ex)
{
YYERROR; // Can't continue, jump to next yyerrok
}
- unit->pushContainer(st);
+ unit->pushContainer(ex);
}
'{' exception_exports '}'
{
unit->popContainer();
}
-| ICE_EXCEPTION keyword
+| local ICE_EXCEPTION keyword exception_extends
{
- unit->error("keyword can not be used as exception name");
+ unit->error("keyword cannot be used as exception name");
}
'{' exception_exports '}'
{
@@ -229,6 +231,21 @@ exception_def
;
// ----------------------------------------------------------------------
+exception_extends
+// ----------------------------------------------------------------------
+: ICE_EXTENDS scoped_name
+{
+ StringTokPtr scoped = StringTokPtr::dynamicCast($2);
+ ContainerPtr cont = unit->currentContainer();
+ $$ = cont->lookupException(scoped->v);
+}
+|
+{
+ $$ = 0;
+}
+;
+
+// ----------------------------------------------------------------------
exception_exports
// ----------------------------------------------------------------------
: exception_export ';' exception_exports
@@ -259,11 +276,11 @@ struct_decl
// ----------------------------------------------------------------------
: ICE_STRUCT ICE_IDENTIFIER
{
- unit->error("structs can not be forward declared");
+ unit->error("structs cannot be forward declared");
}
| ICE_STRUCT keyword
{
- unit->error("keyword can not be used as struct name");
+ unit->error("keyword cannot be used as struct name");
}
;
@@ -287,7 +304,7 @@ struct_def
}
| ICE_STRUCT keyword
{
- unit->error("keyword can not be used as struct name");
+ unit->error("keyword cannot be used as struct name");
}
'{' struct_exports '}'
{
@@ -369,7 +386,7 @@ class_decl
}
| local ICE_CLASS keyword
{
- unit->error("keyword can not be used as class name");
+ unit->error("keyword cannot be used as class name");
}
;
@@ -400,7 +417,7 @@ class_def
}
| local ICE_CLASS keyword class_extends implements
{
- unit->error("keyword can not be used as class name");
+ unit->error("keyword cannot be used as class name");
}
'{' class_exports '}'
{
@@ -474,7 +491,7 @@ interface_decl
}
| local ICE_INTERFACE keyword
{
- unit->error("keyword can not be used as interface name");
+ unit->error("keyword cannot be used as interface name");
}
;
@@ -500,7 +517,7 @@ interface_def
}
| local ICE_INTERFACE keyword interface_extends
{
- unit->error("keyword can not be used as interface name");
+ unit->error("keyword cannot be used as interface name");
}
'{' interface_exports '}'
{
@@ -624,11 +641,11 @@ operation
}
| return_type ICE_OP_KEYWORD parameters output_parameters ')' throws
{
- unit->error("keyword can not be used as operation name");
+ unit->error("keyword cannot be used as operation name");
}
| ICE_NONMUTATING return_type ICE_OP_KEYWORD parameters output_parameters ')' throws
{
- unit->error("keyword can not be used as operation name");
+ unit->error("keyword cannot be used as operation name");
}
;
@@ -663,12 +680,12 @@ parameters
}
| type keyword ',' parameters
{
- unit->error("keyword can not be used as declarator");
+ unit->error("keyword cannot be used as declarator");
$$ = $4
}
| type keyword
{
- unit->error("keyword can not be used as declarator");
+ unit->error("keyword cannot be used as declarator");
$$ = new TypeStringListTok;
}
|
@@ -727,7 +744,7 @@ data_member
}
| type keyword
{
- unit->error("keyword can not be used as data member name");
+ unit->error("keyword cannot be used as data member name");
}
;
@@ -849,16 +866,6 @@ exception_list
exceptionList->v.push_front(exception);
$$ = exceptionList;
}
-| type ',' exception_list
-{
- unit->error("not an exception");
- $$ = $3;
-}
-| type
-{
- unit->error("not an exception");
- $$ = new ExceptionListTok;
-}
;
// ----------------------------------------------------------------------
@@ -890,7 +897,7 @@ sequence_def
}
| ICE_SEQUENCE '<' type '>' keyword
{
- unit->error("keyword can not be used as sequence name");
+ unit->error("keyword cannot be used as sequence name");
}
;
@@ -907,7 +914,7 @@ dictionary_def
}
| ICE_DICTIONARY '<' type ',' type '>' keyword
{
- unit->error("keyword can not be used as dictionary name");
+ unit->error("keyword cannot be used as dictionary name");
}
;
@@ -932,7 +939,7 @@ enum_def
}
| ICE_ENUM keyword
{
- unit->error("keyword can not be used as enum name");
+ unit->error("keyword cannot be used as enum name");
}
'{' enumerator_list '}'
{
@@ -971,7 +978,7 @@ enumerator
}
| keyword
{
- unit->error("keyword can not be used as enumerator");
+ unit->error("keyword cannot be used as enumerator");
EnumeratorListTokPtr ens = new EnumeratorListTok;
$$ = ens;
}
diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp
index e250d3e8468..53c95bc7712 100644
--- a/cpp/src/Slice/Parser.cpp
+++ b/cpp/src/Slice/Parser.cpp
@@ -354,7 +354,7 @@ Slice::Container::createClassDecl(const string& name, bool local, bool intf)
}
ExceptionPtr
-Slice::Container::createException(const string& name)
+Slice::Container::createException(const string& name, bool local, const ExceptionPtr& base)
{
ContainedList matches = _unit->findContents(thisScope() + name);
if (!matches.empty())
@@ -381,7 +381,7 @@ Slice::Container::createException(const string& name)
return 0;
}
- ExceptionPtr p = new Exception(this, name);
+ ExceptionPtr p = new Exception(this, name, local, base);
_contents.push_back(p);
return p;
}
@@ -1510,6 +1510,13 @@ Slice::Proxy::Proxy(const ClassDeclPtr& cl) :
// Exception
// ----------------------------------------------------------------------
+void
+Slice::Exception::destroy()
+{
+ _base = 0;
+ Container::destroy();
+}
+
DataMemberPtr
Slice::Exception::createDataMember(const string& name, const TypePtr& type)
{
@@ -1567,6 +1574,18 @@ Slice::Exception::dataMembers()
return result;
}
+ExceptionPtr
+Slice::Exception::base()
+{
+ return _base;
+}
+
+bool
+Slice::Exception::isLocal()
+{
+ return _local;
+}
+
bool
Slice::Exception::uses(const ConstructedPtr&)
{
@@ -1594,10 +1613,12 @@ Slice::Exception::visit(ParserVisitor* visitor)
}
}
-Slice::Exception::Exception(const ContainerPtr& container, const string& name) :
+Slice::Exception::Exception(const ContainerPtr& container, const string& name, bool local, const ExceptionPtr& base) :
Container(container->unit()),
Contained(container, name),
- SyntaxTreeBase(container->unit())
+ SyntaxTreeBase(container->unit()),
+ _local(local),
+ _base(base)
{
}
diff --git a/cpp/src/slice2docbook/Gen.cpp b/cpp/src/slice2docbook/Gen.cpp
index 1a5760e42a9..1ad59407722 100644
--- a/cpp/src/slice2docbook/Gen.cpp
+++ b/cpp/src/slice2docbook/Gen.cpp
@@ -537,7 +537,21 @@ Slice::Gen::visitExceptionStart(const ExceptionPtr& p)
start("section", "Overview");
O.zeroIndent();
O << nl << "<synopsis>";
- O << "exception <structname>" << p->name() << "</structname>";
+ if (p->isLocal())
+ {
+ O << "local ";
+ }
+ O << "exception <exceptionname>" << p->name() << "</exceptionname>";
+ ExceptionPtr base = p->base();
+ if (base)
+ {
+ O.inc();
+ O << nl << "extends ";
+ O.inc();
+ O << nl << toString(base, p);
+ O.dec();
+ O.dec();
+ }
O << "</synopsis>";
O.restoreIndent();
@@ -1173,7 +1187,7 @@ Slice::Gen::toString(const SyntaxTreeBasePtr& p, const ContainerPtr& container)
{
linkend = containedToId(ex);
s = getScopedMinimized(ex, container);
- tag = "structname";
+ tag = "exceptionname";
}
StructPtr st = StructPtr::dynamicCast(p);