t_field* tfield;
char* dtext;
t_field::e_req ereq;
+ t_annotation* tannot;
}
/**
%type<ttype> BaseType
%type<ttype> ContainerType
+%type<ttype> SimpleContainerType
%type<ttype> MapType
%type<ttype> SetType
%type<ttype> ListType
%type<ttypedef> Typedef
%type<ttype> DefinitionType
+%type<ttype> TypeAnnotations
+%type<ttype> TypeAnnotationList
+%type<tannot> TypeAnnotation
+
%type<tfield> Field
%type<iconst> FieldIdentifier
%type<ereq> FieldRequiredness
}
Struct:
- tok_struct tok_identifier XsdAll '{' FieldList '}'
+ tok_struct tok_identifier XsdAll '{' FieldList '}' TypeAnnotations
{
pdebug("Struct -> tok_struct tok_identifier { FieldList }");
- $5->set_name($2);
$5->set_xsd_all($3);
$$ = $5;
+ $$->set_name($2);
+ if ($7 != NULL) {
+ $$->annotations_ = $7->annotations_;
+ delete $7;
+ }
y_field_val = -1;
}
$$ = g_type_double;
}
-ContainerType:
+ContainerType: SimpleContainerType TypeAnnotations
+ {
+ pdebug("ContainerType -> SimpleContainerType TypeAnnotations");
+ $$ = $1;
+ if ($2 != NULL) {
+ $$->annotations_ = $2->annotations_;
+ delete $2;
+ }
+ }
+
+SimpleContainerType:
MapType
{
- pdebug("ContainerType -> MapType");
+ pdebug("SimpleContainerType -> MapType");
$$ = $1;
}
| SetType
{
- pdebug("ContainerType -> SetType");
+ pdebug("SimpleContainerType -> SetType");
$$ = $1;
}
| ListType
{
- pdebug("ContainerType -> ListType");
+ pdebug("SimpleContainerType -> ListType");
$$ = $1;
}
$$ = NULL;
}
+TypeAnnotations:
+ '(' TypeAnnotationList ')'
+ {
+ pdebug("TypeAnnotations -> ( TypeAnnotationList )");
+ $$ = $2;
+ }
+|
+ {
+ $$ = NULL;
+ }
+
+TypeAnnotationList:
+ TypeAnnotationList TypeAnnotation
+ {
+ pdebug("TypeAnnotationList -> TypeAnnotationList , TypeAnnotation");
+ $$ = $1;
+ $$->annotations_[$2->key] = $2->val;
+ delete $2;
+ }
+|
+ {
+ /* Just use a dummy structure to hold the annotations. */
+ $$ = new t_struct(g_program);
+ }
+
+TypeAnnotation:
+ tok_identifier '=' tok_literal CommaOrSemicolonOptional
+ {
+ pdebug("TypeAnnotation -> tok_identifier = tok_literal");
+ $$ = new t_annotation;
+ $$->key = $1;
+ $$->val = $3;
+ }
+
%%