asn1c code generator modifier: <asn1c:pointer>
git-svn-id: https://asn1c.svn.sourceforge.net/svnroot/asn1c/trunk@976 59561ff5-6e30-0410-9f3c-9617f08c8826
diff --git a/libasn1parser/asn1p_y.y b/libasn1parser/asn1p_y.y
index 13af5a2..28c1f7e 100644
--- a/libasn1parser/asn1p_y.y
+++ b/libasn1parser/asn1p_y.y
@@ -24,6 +24,13 @@
extern int asn1p_lineno;
/*
+ * Process modifiers as <asn1c:pointer>
+ */
+extern int asn1p_as_pointer;
+static asn1p_expr_t *asn1p_last_type;
+static void apply_nonstd_mods(void);
+
+/*
* This temporary variable is used to solve the shortcomings of 1-lookahead
* parser.
*/
@@ -231,6 +238,7 @@
%type <a_expr> ExportsElement
%type <a_expr> ExtensionAndException
%type <a_expr> TypeDeclaration
+%type <a_expr> TypeDeclarationSet
%type <a_ref> ComplexTypeReference
%type <a_ref> ComplexTypeReferenceAmpList
%type <a_refcomp> ComplexTypeReferenceElement
@@ -1086,26 +1094,32 @@
$$->constraints = $3;
}
}
+ asn1p_last_type = $$;
}
;
TypeDeclaration:
+ {apply_nonstd_mods();} TypeDeclarationSet {
+ $$ = $2;
+ }
+
+TypeDeclarationSet:
BasicType {
$$ = $1;
}
- | TOK_CHOICE '{' AlternativeTypeLists '}' {
+ | TOK_CHOICE '{' AlternativeTypeLists {apply_nonstd_mods();} '}' {
$$ = $3;
assert($$->expr_type == A1TC_INVALID);
$$->expr_type = ASN_CONSTR_CHOICE;
$$->meta_type = AMT_TYPE;
}
- | TOK_SEQUENCE '{' optComponentTypeLists '}' {
+ | TOK_SEQUENCE '{' optComponentTypeLists {apply_nonstd_mods();} '}' {
$$ = $3;
assert($$->expr_type == A1TC_INVALID);
$$->expr_type = ASN_CONSTR_SEQUENCE;
$$->meta_type = AMT_TYPE;
}
- | TOK_SET '{' optComponentTypeLists '}' {
+ | TOK_SET '{' optComponentTypeLists {apply_nonstd_mods();} '}' {
$$ = $3;
assert($$->expr_type == A1TC_INVALID);
$$->expr_type = ASN_CONSTR_SET;
@@ -2235,6 +2249,22 @@
expr->Identifier);
}
+static void
+apply_nonstd_mods() {
+ if(!asn1p_as_pointer) return;
+ asn1p_as_pointer = 0;
+
+ if(asn1p_last_type) {
+ asn1p_last_type->marker.flags |= EM_INDIRECT;
+ fprintf(stderr, "INFO: Modifier <asn1c:pointer> "
+ "applied to \"%s\" at line %d\n",
+ asn1p_last_type->Identifier
+ ? asn1p_last_type->Identifier : "<anonymous>",
+ asn1p_last_type->_lineno);
+ asn1p_last_type = 0;
+ }
+}
+
extern char *asn1p_text;
int