authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-05-13 16:51:23+03:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-05-13 16:51:23+03:00
log91358f3092fb2004bb46572d44a0e377ed400565
treeff310c3d77389b7b11544b2d550804acd57029b6
parentdf22c7dfef7312474865c868a633c8e9bbaa63fa
signature Commit is signed but in an unrecognized format.

continue parsing on extra qualifier errors


1 files changed, 43 insertions(+), 10 deletions(-)

lib/std/zig/parse.zig+43-10
......@@ -226,6 +226,10 @@ fn findEndOfBlock(it: *TokenIterator) void {
226226 count -= 1;
227227 if (count == 0) return;
228228 },
229 .Eof => {
230 _ = it.prev();
231 return;
232 },
229233 else => {},
230234 };
231235}
......@@ -242,8 +246,12 @@ fn findToken(it: *TokenIterator, wanted: Token.Id) void {
242246 }
243247 count -= 1;
244248 },
249 .Eof => {
250 _ = it.prev();
251 return;
252 },
245253 else => {
246 if (tok.id == wanted and count == 0) return;
254 if (tok.id == wanted and count == 0) return;
247255 },
248256 };
249257}
......@@ -2324,7 +2332,7 @@ fn parsePrefixTypeOp(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node
23242332 const node = try arena.create(Node.AnyFrameType);
23252333 node.* = .{
23262334 .anyframe_token = token,
2327 .result = Node.AnyFrameType.Result{
2335 .result = .{
23282336 .arrow_token = arrow,
23292337 .return_type = undefined, // set by caller
23302338 },
......@@ -2365,6 +2373,13 @@ fn parsePrefixTypeOp(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node
23652373 } else null;
23662374 _ = try expectToken(it, tree, .RParen);
23672375
2376 if (ptr_info.align_info != null) {
2377 try tree.errors.push(.{
2378 .ExtraAlignQualifier = .{ .token = it.index - 1 },
2379 });
2380 continue;
2381 }
2382
23682383 ptr_info.align_info = Node.PrefixOp.PtrInfo.Align{
23692384 .node = expr_node,
23702385 .bit_range = bit_range,
......@@ -2373,14 +2388,32 @@ fn parsePrefixTypeOp(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node
23732388 continue;
23742389 }
23752390 if (eatToken(it, .Keyword_const)) |const_token| {
2391 if (ptr_info.const_token != null) {
2392 try tree.errors.push(.{
2393 .ExtraConstQualifier = .{ .token = it.index - 1 },
2394 });
2395 continue;
2396 }
23762397 ptr_info.const_token = const_token;
23772398 continue;
23782399 }
23792400 if (eatToken(it, .Keyword_volatile)) |volatile_token| {
2401 if (ptr_info.volatile_token != null) {
2402 try tree.errors.push(.{
2403 .ExtraVolatileQualifier = .{ .token = it.index - 1 },
2404 });
2405 continue;
2406 }
23802407 ptr_info.volatile_token = volatile_token;
23812408 continue;
23822409 }
23832410 if (eatToken(it, .Keyword_allowzero)) |allowzero_token| {
2411 if (ptr_info.allowzero_token != null) {
2412 try tree.errors.push(.{
2413 .ExtraAllowZeroQualifier = .{ .token = it.index - 1 },
2414 });
2415 continue;
2416 }
23842417 ptr_info.allowzero_token = allowzero_token;
23852418 continue;
23862419 }
......@@ -2399,9 +2432,9 @@ fn parsePrefixTypeOp(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node
23992432 if (try parseByteAlign(arena, it, tree)) |align_expr| {
24002433 if (slice_type.align_info != null) {
24012434 try tree.errors.push(.{
2402 .ExtraAlignQualifier = .{ .token = it.index },
2435 .ExtraAlignQualifier = .{ .token = it.index - 1 },
24032436 });
2404 return error.ParseError;
2437 continue;
24052438 }
24062439 slice_type.align_info = Node.PrefixOp.PtrInfo.Align{
24072440 .node = align_expr,
......@@ -2412,9 +2445,9 @@ fn parsePrefixTypeOp(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node
24122445 if (eatToken(it, .Keyword_const)) |const_token| {
24132446 if (slice_type.const_token != null) {
24142447 try tree.errors.push(.{
2415 .ExtraConstQualifier = .{ .token = it.index },
2448 .ExtraConstQualifier = .{ .token = it.index - 1 },
24162449 });
2417 return error.ParseError;
2450 continue;
24182451 }
24192452 slice_type.const_token = const_token;
24202453 continue;
......@@ -2422,9 +2455,9 @@ fn parsePrefixTypeOp(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node
24222455 if (eatToken(it, .Keyword_volatile)) |volatile_token| {
24232456 if (slice_type.volatile_token != null) {
24242457 try tree.errors.push(.{
2425 .ExtraVolatileQualifier = .{ .token = it.index },
2458 .ExtraVolatileQualifier = .{ .token = it.index - 1 },
24262459 });
2427 return error.ParseError;
2460 continue;
24282461 }
24292462 slice_type.volatile_token = volatile_token;
24302463 continue;
......@@ -2432,9 +2465,9 @@ fn parsePrefixTypeOp(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node
24322465 if (eatToken(it, .Keyword_allowzero)) |allowzero_token| {
24332466 if (slice_type.allowzero_token != null) {
24342467 try tree.errors.push(.{
2435 .ExtraAllowZeroQualifier = .{ .token = it.index },
2468 .ExtraAllowZeroQualifier = .{ .token = it.index - 1 },
24362469 });
2437 return error.ParseError;
2470 continue;
24382471 }
24392472 slice_type.allowzero_token = allowzero_token;
24402473 continue;