commit
a2840a6aa7
1 changed files with 7 additions and 8 deletions
|
|
@ -14,16 +14,15 @@ void init_parser(void)
|
|||
const HParser *equals = h_ch('=');
|
||||
|
||||
const HParser *bsfdig = h_choice(alpha, digit, plus, slash, NULL);
|
||||
const HParser *bsfdig_4bit = h_choice(
|
||||
h_ch('A'), h_ch('E'), h_ch('I'), h_ch('M'), h_ch('Q'), h_ch('U'),
|
||||
h_ch('Y'), h_ch('c'), h_ch('g'), h_ch('k'), h_ch('o'), h_ch('s'),
|
||||
h_ch('w'), h_ch('0'), h_ch('4'), h_ch('8'), NULL);
|
||||
const HParser *bsfdig_2bit = h_choice(h_ch('A'), h_ch('Q'), h_ch('g'), h_ch('w'), NULL);
|
||||
const HParser *bsfdig_4bit = h_in((uint8_t *)"AEIMQUYcgkosw048", 16);
|
||||
const HParser *bsfdig_2bit = h_in((uint8_t *)"AQgw", 4);
|
||||
const HParser *base64_3 = h_repeat_n(bsfdig, 4);
|
||||
const HParser *base64_2 = h_sequence(bsfdig, bsfdig, bsfdig_4bit, equals, NULL);
|
||||
const HParser *base64_1 = h_sequence(bsfdig, bsfdig_2bit, equals, equals, NULL);
|
||||
const HParser *base64 = h_choice(base64_2, base64_1, NULL);
|
||||
// why does this parse "A=="?!
|
||||
// why does this parse "aaA=" but not "aA=="?!
|
||||
const HParser *base64 = h_sequence(h_many(base64_3),
|
||||
h_optional(h_choice(base64_2,
|
||||
base64_1, NULL)),
|
||||
NULL);
|
||||
|
||||
document = base64;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue