Skip to content

Commit 42b690a

Browse files
committed
fix rport in Via parser.
1 parent 517a6a2 commit 42b690a

File tree

2 files changed

+70
-47
lines changed

2 files changed

+70
-47
lines changed

lib/src/grammar.peg

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,9 +1094,11 @@ via_branch <- "branch"i EQUAL via_branch: token {
10941094
return data.branch;
10951095
}
10961096

1097-
response_port <- "rport"i (EQUAL response_port: (DIGIT*) )? {
1097+
response_port <- "rport"i EQUAL (response_port: (DIGIT ? DIGIT ? DIGIT ? DIGIT ? DIGIT ?) )? {
10981098
if(response_port != null)
1099-
data.rport = response_port.join(''); }
1099+
data.rport = parseInt(response_port.join(''));
1100+
}
1101+
11001102

11011103
via_extension <- generic_param
11021104

lib/src/grammar_parser.dart

Lines changed: 66 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -13279,81 +13279,102 @@ class GrammarParser {
1327913279
while (true) {
1328013280
$$ = _matchString(_strings74, 'rport', true);
1328113281
if (!success) break;
13282-
var seq = new List(2)..[0] = $$;
13282+
var seq = new List(3)..[0] = $$;
13283+
$$ = _parse_EQUAL();
13284+
if (!success) break;
13285+
seq[1] = $$;
1328313286
var testing0 = _testing;
1328413287
_testing = _cursor;
1328513288
switch (_ch >= 0 && _ch <= 1114111 ? 0 : _ch == -1 ? 2 : 1) {
1328613289
case 0:
1328713290
case 2:
13288-
var ch1 = _ch, pos1 = _cursor, startPos1 = _startPos;
13291+
var startPos1 = _startPos;
1328913292
_startPos = _cursor;
13290-
while (true) {
13291-
$$ = _parse_EQUAL();
13292-
if (!success) break;
13293-
var seq = new List(2)..[0] = $$;
13294-
switch (_ch >= 0 && _ch <= 1114111 ? 0 : _ch == -1 ? 2 : 1) {
13295-
case 0:
13296-
case 2:
13297-
var startPos2 = _startPos;
13298-
_startPos = _cursor;
13299-
var testing1 = _testing;
13300-
for (var reps = []; ; ) {
13301-
_testing = _cursor;
13302-
$$ = _parse_DIGIT();
13303-
if (success) {
13304-
reps.add($$);
13305-
} else {
13306-
success = true;
13307-
_testing = testing1;
13308-
$$ = reps;
13309-
break;
13310-
}
13311-
}
13312-
_startPos = startPos2;
13313-
break;
13314-
case 1:
13315-
$$ = null;
13316-
success = true;
13293+
switch (_ch >= 0 && _ch <= 1114111 ? 0 : _ch == -1 ? 2 : 1) {
13294+
case 0:
13295+
case 2:
13296+
var ch1 = _ch, pos1 = _cursor, startPos2 = _startPos;
13297+
_startPos = _cursor;
13298+
while (true) {
13299+
var testing1 = _testing;
13300+
_testing = _cursor;
13301+
$$ = _parse_DIGIT();
13302+
success = true;
13303+
_testing = testing1;
13304+
if (!success) break;
13305+
var seq = new List(5)..[0] = $$;
13306+
var testing2 = _testing;
13307+
_testing = _cursor;
13308+
$$ = _parse_DIGIT();
13309+
success = true;
13310+
_testing = testing2;
13311+
if (!success) break;
13312+
seq[1] = $$;
13313+
var testing3 = _testing;
13314+
_testing = _cursor;
13315+
$$ = _parse_DIGIT();
13316+
success = true;
13317+
_testing = testing3;
13318+
if (!success) break;
13319+
seq[2] = $$;
13320+
var testing4 = _testing;
13321+
_testing = _cursor;
13322+
$$ = _parse_DIGIT();
13323+
success = true;
13324+
_testing = testing4;
13325+
if (!success) break;
13326+
seq[3] = $$;
13327+
var testing5 = _testing;
13328+
_testing = _cursor;
13329+
$$ = _parse_DIGIT();
13330+
success = true;
13331+
_testing = testing5;
13332+
if (!success) break;
13333+
seq[4] = $$;
13334+
$$ = seq;
1331713335
break;
13318-
}
13319-
if (!success && _cursor > _testing) {
13320-
_failure(_expect14);
13321-
}
13322-
if (!success) break;
13323-
seq[1] = $$;
13324-
$$ = seq;
13325-
break;
13336+
}
13337+
if (!success) {
13338+
_ch = ch1;
13339+
_cursor = pos1;
13340+
}
13341+
_startPos = startPos2;
13342+
break;
13343+
case 1:
13344+
$$ = null;
13345+
success = true;
13346+
break;
1332613347
}
13327-
if (!success) {
13328-
_ch = ch1;
13329-
_cursor = pos1;
13348+
if (!success && _cursor > _testing) {
13349+
_failure(_expect14);
1333013350
}
1333113351
_startPos = startPos1;
1333213352
break;
1333313353
case 1:
1333413354
$$ = null;
13335-
success = false;
13355+
success = true;
1333613356
break;
1333713357
}
1333813358
if (!success && _cursor > _testing) {
13339-
_failure(_expect24);
13359+
_failure(_expect14);
1334013360
}
1334113361
success = true;
1334213362
_testing = testing0;
1334313363
if (!success) break;
13344-
seq[1] = $$;
13364+
seq[2] = $$;
1334513365
$$ = seq;
1334613366
if (success) {
1334713367
final $1 = seq[0];
1334813368
final $2 = seq[1];
13369+
final $3 = seq[2];
1334913370
final $start = startPos0;
1335013371
var pos0 = _startPos;
1335113372
$$ = ((offset, response_port) {
1335213373
///CODE_START
1335313374
if(response_port != null)
13354-
data.rport = response_port.join('');
13375+
data.rport = parseInt(response_port.join(''));
1335513376
///CODE_END
13356-
})($start, $2);
13377+
})($start, $3);
1335713378
}
1335813379
break;
1335913380
}

0 commit comments

Comments
 (0)