Commit 0c68645c authored by Lev Walkin's avatar Lev Walkin

updated parsing bnf

parent 2d0effca
...@@ -173,7 +173,10 @@ main(int ac, char **av) { ...@@ -173,7 +173,10 @@ main(int ac, char **av) {
warnings_as_errors = 1; warnings_as_errors = 1;
break; break;
} else if(strcmp(optarg, "debug-lexer") == 0) { } else if(strcmp(optarg, "debug-lexer") == 0) {
asn1_parser_flags |= A1P_LEXER_DEBUG; asn1_parser_flags |= A1P_DEBUG_LEXER;
break;
} else if(strcmp(optarg, "debug-parser") == 0) {
asn1_parser_flags |= A1P_DEBUG_PARSER;
break; break;
} else if(strcmp(optarg, "debug-fixer") == 0) { } else if(strcmp(optarg, "debug-fixer") == 0) {
asn1_fixer_flags |= A1F_DEBUG; asn1_fixer_flags |= A1F_DEBUG;
...@@ -483,6 +486,7 @@ usage(const char *av0) { ...@@ -483,6 +486,7 @@ usage(const char *av0) {
" -Werror Treat warnings as errors; abort if any warning\n" " -Werror Treat warnings as errors; abort if any warning\n"
" -Wdebug-lexer Enable verbose debugging output from lexer\n" " -Wdebug-lexer Enable verbose debugging output from lexer\n"
" -Wdebug-parser Enable verbose debugging output from parser\n"
" -Wdebug-fixer --//-- semantics processor\n" " -Wdebug-fixer --//-- semantics processor\n"
" -Wdebug-compiler --//-- compiler\n" " -Wdebug-compiler --//-- compiler\n"
"\n" "\n"
......
...@@ -78,6 +78,11 @@ Treat warnings as errors; abort if any warning is produced. ...@@ -78,6 +78,11 @@ Treat warnings as errors; abort if any warning is produced.
.RE .RE
.TP .TP
.B \-Wdebug\-lexer .B \-Wdebug\-lexer
Enable lexer debugging during the ASN.1 lexing stage.
.RS
.RE
.TP
.B \-Wdebug\-parser
Enable lexer debugging during the ASN.1 parsing stage. Enable lexer debugging during the ASN.1 parsing stage.
.RS .RS
.RE .RE
......
...@@ -54,6 +54,9 @@ and other encoding rules. ...@@ -54,6 +54,9 @@ and other encoding rules.
: Treat warnings as errors; abort if any warning is produced. : Treat warnings as errors; abort if any warning is produced.
-Wdebug-lexer -Wdebug-lexer
: Enable lexer debugging during the ASN.1 lexing stage.
-Wdebug-parser
: Enable lexer debugging during the ASN.1 parsing stage. : Enable lexer debugging during the ASN.1 parsing stage.
-Wdebug-fixer -Wdebug-fixer
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -262,7 +262,7 @@ ...@@ -262,7 +262,7 @@
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE typedef union YYSTYPE
#line 90 "asn1p_y.y" #line 115 "asn1p_y.y"
{ {
asn1p_t *a_grammar; asn1p_t *a_grammar;
asn1p_module_flags_e a_module_flags; asn1p_module_flags_e a_module_flags;
......
This diff is collapsed.
...@@ -132,6 +132,7 @@ extern int asn1p_lexer_types_year; ...@@ -132,6 +132,7 @@ extern int asn1p_lexer_types_year;
extern int asn1p_lexer_constructs_year; extern int asn1p_lexer_constructs_year;
extern int asn1p_lexer_extended_values; extern int asn1p_lexer_extended_values;
extern int asn1p__flex_debug; extern int asn1p__flex_debug;
extern int asn1p_debug;
static int static int
_asn1p_set_flags(enum asn1p_flags flags) { _asn1p_set_flags(enum asn1p_flags flags) {
...@@ -139,15 +140,18 @@ _asn1p_set_flags(enum asn1p_flags flags) { ...@@ -139,15 +140,18 @@ _asn1p_set_flags(enum asn1p_flags flags) {
asn1p_lexer_types_year = 0; asn1p_lexer_types_year = 0;
asn1p_lexer_constructs_year = 0; asn1p_lexer_constructs_year = 0;
asn1p__flex_debug = 0; asn1p__flex_debug = 0;
asn1p_debug = 0;
/* if(flags & A1P_DEBUG_LEXER) {
* Enable debugging in lexer. flags &= ~A1P_DEBUG_LEXER;
*/
if(flags & A1P_LEXER_DEBUG) {
flags &= ~A1P_LEXER_DEBUG;
asn1p__flex_debug = 1; asn1p__flex_debug = 1;
} }
if(flags & A1P_DEBUG_PARSER) {
flags &= ~A1P_DEBUG_PARSER;
asn1p_debug = 1;
}
if(flags & A1P_EXTENDED_VALUES) { if(flags & A1P_EXTENDED_VALUES) {
flags &= ~A1P_EXTENDED_VALUES; flags &= ~A1P_EXTENDED_VALUES;
asn1p_lexer_extended_values = 1; asn1p_lexer_extended_values = 1;
......
...@@ -29,13 +29,14 @@ ...@@ -29,13 +29,14 @@
enum asn1p_flags { enum asn1p_flags {
A1P_NOFLAGS, A1P_NOFLAGS,
/* /*
* Enable verbose debugging output from lexer. * Enable verbose debugging output from lexer and parser.
*/ */
A1P_LEXER_DEBUG = 0x01, A1P_DEBUG_LEXER = 0x01,
A1P_DEBUG_PARSER = 0x02,
/* /*
* Unlock internal helper value types. * Unlock internal helper value types.
*/ */
A1P_EXTENDED_VALUES = 0x02 A1P_EXTENDED_VALUES = 0x04
}; };
/* /*
......
...@@ -341,9 +341,6 @@ asn1print_constraint(const asn1p_constraint_t *ct, enum asn1print_flags flags) { ...@@ -341,9 +341,6 @@ asn1print_constraint(const asn1p_constraint_t *ct, enum asn1print_flags flags) {
if(ct == 0) return 0; if(ct == 0) return 0;
if(ct->type == ACT_CA_SET)
safe_printf("(");
switch(ct->type) { switch(ct->type) {
case ACT_EL_TYPE: case ACT_EL_TYPE:
asn1print_value(ct->containedSubtype, flags); asn1print_value(ct->containedSubtype, flags);
...@@ -373,14 +370,13 @@ asn1print_constraint(const asn1p_constraint_t *ct, enum asn1print_flags flags) { ...@@ -373,14 +370,13 @@ asn1print_constraint(const asn1p_constraint_t *ct, enum asn1print_flags flags) {
case ACT_CT_SIZE: case ACT_CT_SIZE:
case ACT_CT_FROM: case ACT_CT_FROM:
switch(ct->type) { switch(ct->type) {
case ACT_CT_SIZE: safe_printf("SIZE("); break; case ACT_CT_SIZE: safe_printf("SIZE"); break;
case ACT_CT_FROM: safe_printf("FROM("); break; case ACT_CT_FROM: safe_printf("FROM"); break;
default: safe_printf("??? ("); break; default: safe_printf("??? "); break;
} }
assert(ct->el_count != 0); assert(ct->el_count != 0);
assert(ct->el_count == 1); assert(ct->el_count == 1);
asn1print_constraint(ct->elements[0], flags); asn1print_constraint(ct->elements[0], flags);
safe_printf(")");
break; break;
case ACT_CT_WCOMP: case ACT_CT_WCOMP:
assert(ct->el_count != 0); assert(ct->el_count != 0);
...@@ -431,6 +427,7 @@ asn1print_constraint(const asn1p_constraint_t *ct, enum asn1print_flags flags) { ...@@ -431,6 +427,7 @@ asn1print_constraint(const asn1p_constraint_t *ct, enum asn1print_flags flags) {
char *symtable[] = { " EXCEPT ", " ^ ", " | ", ",", char *symtable[] = { " EXCEPT ", " ^ ", " | ", ",",
"", "(" }; "", "(" };
unsigned int i; unsigned int i;
if(ct->type == ACT_CA_SET) safe_printf("(");
for(i = 0; i < ct->el_count; i++) { for(i = 0; i < ct->el_count; i++) {
if(i) safe_printf("%s", symtable[symno]); if(i) safe_printf("%s", symtable[symno]);
if(ct->type == ACT_CA_CRC) safe_printf("{"); if(ct->type == ACT_CA_CRC) safe_printf("{");
...@@ -439,6 +436,7 @@ asn1print_constraint(const asn1p_constraint_t *ct, enum asn1print_flags flags) { ...@@ -439,6 +436,7 @@ asn1print_constraint(const asn1p_constraint_t *ct, enum asn1print_flags flags) {
if(ct->type == ACT_CA_SET && i+1 < ct->el_count) if(ct->type == ACT_CA_SET && i+1 < ct->el_count)
safe_printf(") "); safe_printf(") ");
} }
if(ct->type == ACT_CA_SET) safe_printf(")");
} }
break; break;
case ACT_CA_AEX: case ACT_CA_AEX:
...@@ -457,9 +455,6 @@ asn1print_constraint(const asn1p_constraint_t *ct, enum asn1print_flags flags) { ...@@ -457,9 +455,6 @@ asn1print_constraint(const asn1p_constraint_t *ct, enum asn1print_flags flags) {
asn1print_constraint(ct->elements[0], flags); asn1print_constraint(ct->elements[0], flags);
} }
if(ct->type == ACT_CA_SET)
safe_printf(")");
return 0; return 0;
} }
......
...@@ -20,13 +20,16 @@ BEGIN ...@@ -20,13 +20,16 @@ BEGIN
G-3-3 ::= INTEGER (0..10,...)(2..5,...)(3) -- OER-visible constraint 3 G-3-3 ::= INTEGER (0..10,...)(2..5,...)(3) -- OER-visible constraint 3
-- X.696 #8.2.4 Not OER-visible parts of INTERSECTION are ignored -- X.696 #8.2.4 Not OER-visible parts of INTERSECTION are ignored
H-4-5 ::= INTEGER ((0..5) ^ (4..9)) -- OER-visible constraint 4..5 H-4-5 ::= INTEGER ((0..5) ^ (4..9)) -- OER-visible constraint 4..5
I-0-5 ::= INTEGER ((0..5) ^ (4..12,...)) -- OER-visible constraint 0..5 I-1-5 ::= INTEGER ((0..5) ^ (EConstr)) -- OER-visible constraint 1..5
J-4-9 ::= INTEGER ((0..5,...) ^ (4..9)) -- OER-visible constraint 4..9 J-4-5 ::= INTEGER ((EConstr) ^ (4..9)) -- OER-visible constraint 4..5
K-inv ::= INTEGER ((0..5,...) ^ (4..9,...)) -- Not OER-visible K-1-4 ::= INTEGER ((FConstr) ^ (EConstr)) -- OER-visible constraint 1..4
-- X.696 #8.2.5 UNION with exeptions are ignored -- X.696 #8.2.5 UNION with exeptions are ignored
L-0-5 ::= INTEGER ((0) | (5)) -- OER-visible constraint 0..5 L-0-5 ::= INTEGER ((0) | (5)) -- OER-visible constraint 0..5
M-inv ::= INTEGER ((0) | (5,...)) -- Not OER-visible M-inv ::= INTEGER ((0) | (EConstr),...) -- Not OER-visible
N-inv ::= INTEGER ((0..4,...) | (5)) -- Not OER-visible N-0-5 ::= INTEGER ((FConstr) | (5)) -- OER-visible constraint 0..5
O-inv ::= INTEGER ((0..4,...) | (5,...)) -- Not OER-visible O-inv ::= INTEGER ((FConstr) | (5), ...) -- Not OER-visible
EConstr ::= INTEGER (1..5,...)
FConstr ::= INTEGER (0..4)
END END
...@@ -24,7 +24,7 @@ BEGIN ...@@ -24,7 +24,7 @@ BEGIN
other-ten Int2 ::= 10 other-ten Int2 ::= 10
-- G.4.3.4 -- G.4.3.4
ExtensibleExtensions ::= INTEGER ((1..256,...) INTERSECTION (1..256)) ExtensibleExtensions ::= INTEGER (1..256) (1..255,...)
Str1 ::= IA5String Str1 ::= IA5String
Str2 ::= Str1 (SIZE(MIN..20 | 25..30)) Str2 ::= Str1 (SIZE(MIN..20 | 25..30))
......
...@@ -405,7 +405,7 @@ ExtensibleExtensions_constraint(asn_TYPE_descriptor_t *td, const void *sptr, ...@@ -405,7 +405,7 @@ ExtensibleExtensions_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
return -1; return -1;
} }
if((value >= 1 && value <= 256)) { if((value >= 1 && value <= 255)) {
/* Constraint check succeeded */ /* Constraint check succeeded */
return 0; return 0;
} else { } else {
......
...@@ -427,7 +427,7 @@ ExtensibleExtensions_constraint(asn_TYPE_descriptor_t *td, const void *sptr, ...@@ -427,7 +427,7 @@ ExtensibleExtensions_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
value = *(const long *)sptr; value = *(const long *)sptr;
if((value >= 1 && value <= 256)) { if((value >= 1 && value <= 255)) {
/* Constraint check succeeded */ /* Constraint check succeeded */
return 0; return 0;
} else { } else {
...@@ -446,7 +446,7 @@ ExtensibleExtensions_constraint(asn_TYPE_descriptor_t *td, const void *sptr, ...@@ -446,7 +446,7 @@ ExtensibleExtensions_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
/*** <<< CTDEFS [ExtensibleExtensions] >>> ***/ /*** <<< CTDEFS [ExtensibleExtensions] >>> ***/
static asn_per_constraints_t asn_PER_type_ExtensibleExtensions_constr_1 GCC_NOTUSED = { static asn_per_constraints_t asn_PER_type_ExtensibleExtensions_constr_1 GCC_NOTUSED = {
{ APC_CONSTRAINED | APC_EXTENSIBLE, 8, 8, 1, 256 } /* (1..256,...) */, { APC_CONSTRAINED | APC_EXTENSIBLE, 8, 8, 1, 255 } /* (1..255,...) */,
{ APC_UNCONSTRAINED, -1, -1, 0, 0 }, { APC_UNCONSTRAINED, -1, -1, 0, 0 },
0, 0 /* No PER value map */ 0, 0 /* No PER value map */
}; };
......
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