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

updated parsing bnf

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