Commit f4069d22 authored by Lev Walkin's avatar Lev Walkin

print double parametrization

parent 8a7af0e7
...@@ -10,7 +10,10 @@ ...@@ -10,7 +10,10 @@
#include "asn1print.h" #include "asn1print.h"
#define INDENT(fmt, args...) do { \ #define INDENT(fmt, args...) do { \
int __i = level; while(__i--) printf(" "); \ if(!(flags & APF_NOINDENT)) { \
int __i = level; \
while(__i--) printf(" "); \
} \
printf(fmt, ##args); \ printf(fmt, ##args); \
} while(0) } while(0)
...@@ -460,7 +463,7 @@ static int ...@@ -460,7 +463,7 @@ static int
asn1print_expr(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *tc, enum asn1print_flags flags, int level) { asn1print_expr(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *tc, enum asn1print_flags flags, int level) {
int SEQ_OF = 0; int SEQ_OF = 0;
if(flags & APF_LINE_COMMENTS) if(flags & APF_LINE_COMMENTS && !(flags & APF_NOINDENT))
INDENT("-- #line %d\n", tc->_lineno); INDENT("-- #line %d\n", tc->_lineno);
if(tc->Identifier) if(tc->Identifier)
INDENT("%s", tc->Identifier); INDENT("%s", tc->Identifier);
...@@ -473,7 +476,7 @@ asn1print_expr(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *tc, enum asn1pri ...@@ -473,7 +476,7 @@ asn1print_expr(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *tc, enum asn1pri
&& tc->meta_type != AMT_VALUESET && tc->meta_type != AMT_VALUESET
&& tc->expr_type != A1TC_EXTENSIBLE) { && tc->expr_type != A1TC_EXTENSIBLE) {
if(level) { if(level) {
if(tc->Identifier) if(tc->Identifier && !(flags & APF_NOINDENT))
printf("\t"); printf("\t");
} else { } else {
printf(" ::="); printf(" ::=");
...@@ -496,9 +499,10 @@ asn1print_expr(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *tc, enum asn1pri ...@@ -496,9 +499,10 @@ asn1print_expr(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *tc, enum asn1pri
SEQ_OF = 1; /* Equivalent to SET OF for printint purposes */ SEQ_OF = 1; /* Equivalent to SET OF for printint purposes */
printf(" COMPONENTS OF"); printf(" COMPONENTS OF");
break; break;
case A1TC_PARAMETRIZED:
flags |= APF_NOINDENT;
case A1TC_REFERENCE: case A1TC_REFERENCE:
case A1TC_UNIVERVAL: case A1TC_UNIVERVAL:
case A1TC_PARAMETRIZED:
break; break;
case A1TC_CLASSDEF: case A1TC_CLASSDEF:
printf(" CLASS"); printf(" CLASS");
...@@ -528,7 +532,8 @@ asn1print_expr(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *tc, enum asn1pri ...@@ -528,7 +532,8 @@ asn1print_expr(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *tc, enum asn1pri
} }
if(tc->reference) { if(tc->reference) {
printf(" "); if(!(flags & APF_NOINDENT))
printf(" ");
asn1print_ref(tc->reference, flags); asn1print_ref(tc->reference, flags);
} }
...@@ -548,10 +553,17 @@ asn1print_expr(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *tc, enum asn1pri ...@@ -548,10 +553,17 @@ asn1print_expr(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *tc, enum asn1pri
int put_braces = !SEQ_OF; /* Don't need 'em, if SET OF... */ int put_braces = !SEQ_OF; /* Don't need 'em, if SET OF... */
if(put_braces) { if(put_braces) {
printf(" {"); if(flags & APF_NOINDENT) {
if(TQ_FIRST(&tc->members)) printf("{");
printf("\n"); if(!TQ_FIRST(&tc->members))
else printf(" }"); printf("}");
} else {
printf(" {");
if(TQ_FIRST(&tc->members))
printf("\n");
else
printf(" }");
}
} }
TQ_FOR(se, &(tc->members), next) { TQ_FOR(se, &(tc->members), next) {
...@@ -568,12 +580,14 @@ asn1print_expr(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *tc, enum asn1pri ...@@ -568,12 +580,14 @@ asn1print_expr(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *tc, enum asn1pri
} }
if(TQ_NEXT(se, next)) { if(TQ_NEXT(se, next)) {
printf(","); printf(",");
INDENT("\n"); if(!(flags & APF_NOINDENT))
INDENT("\n");
} }
} }
if(put_braces && TQ_FIRST(&tc->members)) { if(put_braces && TQ_FIRST(&tc->members)) {
printf("\n"); if(!(flags & APF_NOINDENT))
printf("\n");
INDENT("}"); INDENT("}");
} }
} }
...@@ -605,7 +619,7 @@ asn1print_expr(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *tc, enum asn1pri ...@@ -605,7 +619,7 @@ asn1print_expr(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *tc, enum asn1pri
} }
/* /*
* The following section exists entirely for debugging only. * The following section exists entirely for debugging.
*/ */
if(flags & APF_DEBUG_CONSTRAINTS if(flags & APF_DEBUG_CONSTRAINTS
&& tc->expr_type != A1TC_EXTENSIBLE) { && tc->expr_type != A1TC_EXTENSIBLE) {
......
...@@ -6,6 +6,7 @@ enum asn1print_flags { ...@@ -6,6 +6,7 @@ enum asn1print_flags {
APF_LINE_COMMENTS = 0x01, /* Include line comments */ APF_LINE_COMMENTS = 0x01, /* Include line comments */
APF_DEBUG_CONSTRAINTS = 0x02, /* Explain constraints */ APF_DEBUG_CONSTRAINTS = 0x02, /* Explain constraints */
APF_PRINT_XML_DTD = 0x04, /* Generate XML DTD */ APF_PRINT_XML_DTD = 0x04, /* Generate XML DTD */
APF_NOINDENT = 0x08, /* Disable indentation */
}; };
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment