| ... | ... | @@ -226,6 +226,10 @@ fn findEndOfBlock(it: *TokenIterator) void { |
| 226 | 226 | count -= 1; |
| 227 | 227 | if (count == 0) return; |
| 228 | 228 | }, |
| 229 | .Eof => { |
| 230 | _ = it.prev(); |
| 231 | return; |
| 232 | }, |
| 229 | 233 | else => {}, |
| 230 | 234 | }; |
| 231 | 235 | } |
| ... | ... | @@ -242,8 +246,12 @@ fn findToken(it: *TokenIterator, wanted: Token.Id) void { |
| 242 | 246 | } |
| 243 | 247 | count -= 1; |
| 244 | 248 | }, |
| 249 | .Eof => { |
| 250 | _ = it.prev(); |
| 251 | return; |
| 252 | }, |
| 245 | 253 | else => { |
| 246 | | if (tok.id == wanted and count == 0) return; |
| 254 | if (tok.id == wanted and count == 0) return; |
| 247 | 255 | }, |
| 248 | 256 | }; |
| 249 | 257 | } |
| ... | ... | @@ -2324,7 +2332,7 @@ fn parsePrefixTypeOp(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node |
| 2324 | 2332 | const node = try arena.create(Node.AnyFrameType); |
| 2325 | 2333 | node.* = .{ |
| 2326 | 2334 | .anyframe_token = token, |
| 2327 | | .result = Node.AnyFrameType.Result{ |
| 2335 | .result = .{ |
| 2328 | 2336 | .arrow_token = arrow, |
| 2329 | 2337 | .return_type = undefined, // set by caller |
| 2330 | 2338 | }, |
| ... | ... | @@ -2365,6 +2373,13 @@ fn parsePrefixTypeOp(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node |
| 2365 | 2373 | } else null; |
| 2366 | 2374 | _ = try expectToken(it, tree, .RParen); |
| 2367 | 2375 | |
| 2376 | if (ptr_info.align_info != null) { |
| 2377 | try tree.errors.push(.{ |
| 2378 | .ExtraAlignQualifier = .{ .token = it.index - 1 }, |
| 2379 | }); |
| 2380 | continue; |
| 2381 | } |
| 2382 | |
| 2368 | 2383 | ptr_info.align_info = Node.PrefixOp.PtrInfo.Align{ |
| 2369 | 2384 | .node = expr_node, |
| 2370 | 2385 | .bit_range = bit_range, |
| ... | ... | @@ -2373,14 +2388,32 @@ fn parsePrefixTypeOp(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node |
| 2373 | 2388 | continue; |
| 2374 | 2389 | } |
| 2375 | 2390 | 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 | } |
| 2376 | 2397 | ptr_info.const_token = const_token; |
| 2377 | 2398 | continue; |
| 2378 | 2399 | } |
| 2379 | 2400 | 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 | } |
| 2380 | 2407 | ptr_info.volatile_token = volatile_token; |
| 2381 | 2408 | continue; |
| 2382 | 2409 | } |
| 2383 | 2410 | 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 | } |
| 2384 | 2417 | ptr_info.allowzero_token = allowzero_token; |
| 2385 | 2418 | continue; |
| 2386 | 2419 | } |
| ... | ... | @@ -2399,9 +2432,9 @@ fn parsePrefixTypeOp(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node |
| 2399 | 2432 | if (try parseByteAlign(arena, it, tree)) |align_expr| { |
| 2400 | 2433 | if (slice_type.align_info != null) { |
| 2401 | 2434 | try tree.errors.push(.{ |
| 2402 | | .ExtraAlignQualifier = .{ .token = it.index }, |
| 2435 | .ExtraAlignQualifier = .{ .token = it.index - 1 }, |
| 2403 | 2436 | }); |
| 2404 | | return error.ParseError; |
| 2437 | continue; |
| 2405 | 2438 | } |
| 2406 | 2439 | slice_type.align_info = Node.PrefixOp.PtrInfo.Align{ |
| 2407 | 2440 | .node = align_expr, |
| ... | ... | @@ -2412,9 +2445,9 @@ fn parsePrefixTypeOp(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node |
| 2412 | 2445 | if (eatToken(it, .Keyword_const)) |const_token| { |
| 2413 | 2446 | if (slice_type.const_token != null) { |
| 2414 | 2447 | try tree.errors.push(.{ |
| 2415 | | .ExtraConstQualifier = .{ .token = it.index }, |
| 2448 | .ExtraConstQualifier = .{ .token = it.index - 1 }, |
| 2416 | 2449 | }); |
| 2417 | | return error.ParseError; |
| 2450 | continue; |
| 2418 | 2451 | } |
| 2419 | 2452 | slice_type.const_token = const_token; |
| 2420 | 2453 | continue; |
| ... | ... | @@ -2422,9 +2455,9 @@ fn parsePrefixTypeOp(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node |
| 2422 | 2455 | if (eatToken(it, .Keyword_volatile)) |volatile_token| { |
| 2423 | 2456 | if (slice_type.volatile_token != null) { |
| 2424 | 2457 | try tree.errors.push(.{ |
| 2425 | | .ExtraVolatileQualifier = .{ .token = it.index }, |
| 2458 | .ExtraVolatileQualifier = .{ .token = it.index - 1 }, |
| 2426 | 2459 | }); |
| 2427 | | return error.ParseError; |
| 2460 | continue; |
| 2428 | 2461 | } |
| 2429 | 2462 | slice_type.volatile_token = volatile_token; |
| 2430 | 2463 | continue; |
| ... | ... | @@ -2432,9 +2465,9 @@ fn parsePrefixTypeOp(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node |
| 2432 | 2465 | if (eatToken(it, .Keyword_allowzero)) |allowzero_token| { |
| 2433 | 2466 | if (slice_type.allowzero_token != null) { |
| 2434 | 2467 | try tree.errors.push(.{ |
| 2435 | | .ExtraAllowZeroQualifier = .{ .token = it.index }, |
| 2468 | .ExtraAllowZeroQualifier = .{ .token = it.index - 1 }, |
| 2436 | 2469 | }); |
| 2437 | | return error.ParseError; |
| 2470 | continue; |
| 2438 | 2471 | } |
| 2439 | 2472 | slice_type.allowzero_token = allowzero_token; |
| 2440 | 2473 | continue; |