From 4463793983f3b0bc7a3637309b14f832ec11db81 Mon Sep 17 00:00:00 2001 From: Nikolay Sokolov Date: Tue, 11 Oct 2022 23:26:49 -0700 Subject: [PATCH] Fix handling of named bits in BIT STRING Bug: #2 --- asn1.y | 2 +- y.go | 137 ++++++++++++++++++++++++++++----------------------------- 2 files changed, 69 insertions(+), 70 deletions(-) diff --git a/asn1.y b/asn1.y index 60680f3..e46de72 100644 --- a/asn1.y +++ b/asn1.y @@ -642,7 +642,7 @@ BitStringType : BIT STRING { $$ = BitStringType{} } ; NamedBitList : NamedBit { $$ = append(make([]NamedBit, 0), $1) } - | NamedBitList "," NamedBit { $$ = append($1, $3) } + | NamedBitList COMMA NamedBit { $$ = append($1, $3) } ; NamedBit : identifier OPEN_ROUND number CLOSE_ROUND { $$ = NamedBit{Name: Identifier($1), Index: $3} } diff --git a/y.go b/y.go index d232036..e94e00b 100644 --- a/y.go +++ b/y.go @@ -324,7 +324,6 @@ var yyToknames = [...]string{ "\"t\"", "\"o\"", "\"d\"", - "\",\"", } var yyStatenames = [...]string{} @@ -375,27 +374,27 @@ var yyAct = [...]int16{ 219, 205, 407, 218, 372, 208, 348, 220, 127, 17, 193, 177, 257, 315, 311, 17, 279, 289, 238, 331, 202, 275, 249, 163, 260, 210, 182, 184, 245, 217, - 170, 180, 159, 362, 323, 341, 195, 19, 252, 386, - 308, 240, 252, 165, 144, 151, 5, 45, 3, 293, - 19, 168, 38, 415, 29, 11, 9, 19, 19, 133, - 263, 271, 324, 19, 168, 272, 295, 294, 204, 165, - 19, 332, 233, 232, 225, 190, 19, 224, 227, 169, - 204, 234, 165, 19, 21, 24, 35, 410, 150, 62, - 215, 65, 169, 204, 31, 19, 168, 23, 22, 36, - 10, 125, 148, 416, 334, 134, 129, 152, 137, 142, - 264, 258, 172, 261, 165, 140, 121, 334, 42, 414, - 61, 128, 60, 162, 169, 172, 128, 58, 164, 161, - 164, 368, 428, 211, 214, 307, 162, 155, 203, 145, - 342, 135, 161, 123, 223, 50, 241, 128, 226, 231, - 399, 139, 171, 221, 221, 241, 216, 172, 213, 241, - 59, 228, 241, 241, 239, 171, 221, 251, 162, 244, - 229, 154, 221, 222, 161, 138, 143, 139, 230, 221, - 246, 124, 141, 235, 236, 122, 266, 243, 46, 164, - 47, 48, 398, 267, 316, 63, 41, 171, 387, 269, - 256, 276, 383, 382, 329, 318, 126, 32, 136, 128, - 268, 343, 254, 313, 286, 27, 103, 281, 253, 430, - 429, 287, 317, 128, 288, 421, 54, 419, 405, 402, - 429, 290, 297, 299, 394, 393, 306, 385, 54, 40, + 170, 180, 159, 362, 323, 386, 195, 19, 252, 240, + 308, 252, 165, 144, 45, 3, 5, 293, 38, 151, + 19, 168, 29, 415, 11, 9, 271, 19, 19, 133, + 272, 19, 324, 295, 233, 294, 263, 204, 204, 165, + 19, 332, 410, 232, 225, 224, 19, 227, 215, 169, + 204, 190, 234, 24, 140, 23, 62, 22, 35, 21, + 128, 65, 150, 36, 31, 148, 261, 258, 134, 10, + 129, 125, 42, 416, 334, 58, 121, 61, 137, 142, + 60, 152, 172, 19, 168, 316, 264, 19, 168, 414, + 139, 428, 128, 162, 266, 47, 48, 368, 164, 161, + 164, 267, 165, 211, 214, 50, 165, 155, 203, 145, + 123, 135, 169, 317, 223, 241, 169, 128, 226, 231, + 399, 141, 171, 221, 221, 241, 216, 221, 213, 241, + 241, 228, 241, 122, 239, 124, 221, 251, 154, 244, + 229, 334, 221, 222, 40, 172, 46, 139, 230, 172, + 246, 138, 143, 235, 236, 63, 162, 243, 59, 164, + 162, 307, 161, 398, 387, 383, 161, 382, 329, 269, + 256, 276, 318, 126, 32, 128, 343, 254, 136, 313, + 268, 286, 27, 253, 54, 171, 103, 281, 430, 171, + 128, 429, 341, 421, 41, 342, 54, 287, 419, 429, + 288, 405, 297, 299, 402, 290, 306, 394, 393, 385, 303, 305, 282, 380, 280, 370, 300, 292, 251, 251, 285, 284, 44, 278, 53, 44, 259, 62, 273, 424, 392, 296, 298, 164, 164, 363, 53, 164, 361, 302, @@ -466,64 +465,64 @@ var yyAct = [...]int16{ } var yyPact = [...]int16{ - 344, -1000, -73, 283, -1000, -8, -1000, 322, 12, 20, - 19, 7, 273, 322, -1000, -1000, -1000, 183, -1000, -1000, - 309, -58, -1000, -1000, -1000, -1000, -1000, 333, 27, -1000, - 174, 18, -1000, 47, -64, 184, -1000, 341, 339, 80, - 78, 227, -1000, -1000, -1000, -1000, -1000, -1000, -1000, 341, - -1000, -1000, -1000, 306, 782, -1000, 74, 339, -1000, 59, - -1000, -1000, 339, -1000, 782, 191, -1000, -1000, -1000, -1000, + 344, -1000, -73, 283, -1000, -9, -1000, 322, 17, 9, + 7, 5, 273, 322, -1000, -1000, -1000, 180, -1000, -1000, + 309, -60, -1000, -1000, -1000, -1000, -1000, 333, 27, -1000, + 171, 20, -1000, 41, -68, 119, -1000, 341, 339, 68, + 65, 227, -1000, -1000, -1000, -1000, -1000, -1000, -1000, 341, + -1000, -1000, -1000, 306, 782, -1000, 64, 339, -1000, 56, + -1000, -1000, 339, -1000, 782, 188, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, 40, -1000, - -1000, -1000, 282, 281, 278, -1000, -45, 39, -1000, 115, - 89, -84, 631, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, 36, - -14, -1000, -1000, 344, -1000, 177, 88, -1000, 383, 277, - 308, 342, 342, -1000, -1000, 63, 708, -16, -19, 177, - 51, 708, -20, -21, -2, 177, 782, 782, -1000, 33, - -1000, -1000, -1000, -1000, 17, -1000, -1000, -1000, -1000, -1000, - -1000, -1000, -1000, -1000, -1000, 30, -1000, -1000, 187, 331, - -1000, -1000, -1000, 66, -1000, -1000, 226, -1000, -1000, 53, - -1000, 16, -1000, 140, -1000, 53, -1000, 383, -1000, -1000, - -1000, -1000, -1000, -1000, 304, 177, -38, 230, -1000, 342, - 271, 223, 214, -1000, 66, 782, 258, 221, -1000, 220, - -1000, 182, 194, -1000, 182, -1000, 201, 257, 217, -1000, - -48, -27, 177, -1000, 708, 708, -1000, -1000, 201, 256, - 177, -1000, 708, 708, 342, 177, 177, 100, -1000, -1000, + -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, 34, -1000, + -1000, -1000, 282, 281, 278, -1000, -45, 32, -1000, 115, + 58, -85, 631, -1000, -1000, -1000, -1000, -1000, -1000, -1000, + -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, 29, + -10, -1000, -1000, 344, -1000, 173, 106, -1000, 383, 277, + 308, 342, 342, -1000, -1000, 51, 708, -18, -19, 173, + 50, 708, -20, -29, -1, 173, 782, 782, -1000, 31, + -1000, -1000, -1000, -1000, 16, -1000, -1000, -1000, -1000, -1000, + -1000, -1000, -1000, -1000, -1000, 30, -1000, -1000, 182, 331, + -1000, -1000, -1000, 52, -1000, -1000, 226, -1000, -1000, 36, + -1000, 22, -1000, 78, -1000, 36, -1000, 383, -1000, -1000, + -1000, -1000, -1000, -1000, 304, 173, -43, 230, -1000, 342, + 271, 223, 214, -1000, 52, 782, 258, 221, -1000, 220, + -1000, 179, 200, -1000, 179, -1000, 205, 257, 217, -1000, + -50, -30, 173, -1000, 708, 708, -1000, -1000, 205, 256, + 173, -1000, 708, 708, 342, 173, 173, 156, -1000, -1000, -1000, -90, -1000, -1000, -1000, 250, 30, 30, -1000, -1000, - -1000, 181, -1000, 330, 186, 187, -1000, 172, 557, 302, - -1000, 470, 470, -1000, -1000, 470, -1000, -1000, -1000, 171, - 43, 177, 276, -1000, 8, -1000, 179, -1000, 308, 201, - 342, -1000, 177, -1000, 301, 342, 26, -1000, 342, 244, - 300, -1000, 76, -1000, 88, 782, 177, -1000, 177, -1000, - 241, -1000, 177, -1000, 177, -1000, -1000, -1000, -98, -1000, - 238, -1000, -1000, 34, 286, -1000, -1000, 327, -1000, -1000, - -1000, -1000, 94, -1000, 325, 215, -1000, -1000, -1000, -1000, - -1000, -1000, 56, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - 305, -1000, 342, 33, 214, -1000, -1000, 213, -1000, -1000, - 66, -1000, 170, 169, -1000, -1000, -1000, 207, -1000, -1000, - 177, -1000, -91, -1000, 165, -1000, 186, -1000, 88, -1000, - 383, -1000, 233, 205, 204, 177, -1000, 159, 117, 201, - 342, 199, -1000, -1000, 198, 69, -1000, -1000, -1000, -1000, + -1000, 177, -1000, 330, 107, 182, -1000, 169, 557, 302, + -1000, 470, 470, -1000, -1000, 470, -1000, -1000, -1000, 165, + 43, 173, 276, -1000, 195, -1000, 174, -1000, 308, 205, + 342, -1000, 173, -1000, 301, 342, 26, -1000, 342, 244, + 300, -1000, 63, -1000, 106, 782, 173, -1000, 173, -1000, + 241, -1000, 173, -1000, 173, -1000, -1000, -1000, -98, -1000, + 238, -1000, -1000, 33, 286, -1000, -1000, 327, -1000, -1000, + -1000, -1000, 90, -1000, 325, 215, -1000, -1000, -1000, -1000, + -1000, -1000, 110, -1000, -1000, -1000, -1000, -1000, -1000, -1000, + 305, -1000, 342, 31, 214, -1000, -1000, 213, -1000, -1000, + 52, -1000, 164, 162, -1000, -1000, -1000, 209, -1000, -1000, + 173, -1000, -95, -1000, 161, -1000, 107, -1000, 106, -1000, + 383, -1000, 233, 208, 207, 173, -1000, 160, 117, 205, + 342, 204, -1000, -1000, 201, 54, -1000, -1000, -1000, -1000, -1000, -1000, -1000, 342, 342, -1000, 6, -1000, -1000, -1000, - -1000, -1000, 342, -1000, 197, 299, 195, -1000, -1000, -1000, - 319, 232, -1000, -1000, -1000, -1000, -1000, -1000, -1000, 50, - -1000, 69, 50, 95, -1000, 190, -1000, 200, -1000, 50, + -1000, -1000, 342, -1000, 198, 299, 193, -1000, -1000, -1000, + 319, 232, -1000, -1000, -1000, -1000, -1000, -1000, -1000, 69, + -1000, 54, 69, 84, -1000, 191, -1000, 199, -1000, 69, -1000, } var yyPgo = [...]int16{ - 0, 30, 13, 47, 216, 1, 529, 525, 523, 522, + 0, 30, 13, 44, 216, 1, 529, 525, 523, 522, 278, 326, 521, 520, 323, 14, 518, 517, 516, 515, 36, 514, 513, 512, 7, 511, 22, 507, 28, 32, 503, 10, 499, 498, 495, 494, 491, 490, 23, 18, - 145, 488, 487, 486, 485, 188, 484, 482, 8, 481, + 135, 488, 487, 486, 485, 176, 484, 482, 8, 481, 480, 473, 468, 467, 11, 466, 461, 31, 459, 26, - 24, 27, 455, 453, 451, 450, 449, 447, 75, 446, + 24, 27, 455, 453, 451, 450, 449, 447, 81, 446, 444, 443, 19, 442, 436, 435, 434, 433, 431, 429, 428, 427, 0, 3, 427, 29, 425, 421, 420, 418, - 416, 414, 413, 412, 21, 411, 410, 407, 127, 160, - 118, 406, 405, 403, 401, 400, 394, 394, 6, 16, + 416, 414, 413, 412, 21, 411, 410, 407, 105, 188, + 102, 406, 405, 403, 401, 400, 394, 394, 6, 16, 393, 392, 385, 383, 381, 25, 378, 377, 12, 376, 5, 375, 20, 17, 374, 373, 371, 2, 369, 368, 368, 367, 366, 365, 360, 359, 357, 4, 356, 355, @@ -631,7 +630,7 @@ var yyChk = [...]int16{ -28, -15, -28, 32, 8, -2, 8, 36, 33, -142, -38, -15, -20, 8, 36, 17, -61, -57, -59, 33, -70, -72, 28, -31, 61, -133, -48, -134, -135, -136, - 26, 27, 132, 32, -122, -24, -123, -110, -108, -24, + 26, 27, 30, 32, -122, -24, -123, -110, -108, -24, 17, -120, -38, -15, -115, 27, 17, -122, -82, -31, -20, 27, 131, 27, -26, -15, 25, 8, 37, 8, 30, -72, -137, 17, -138, -5, -94, -39, -15, -109, @@ -695,7 +694,7 @@ var yyTok1 = [...]uint8{ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 132, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,