@@ -262,6 +262,9 @@ pub fn renderError(tree: Tree, parse_error: Error, stream: anytype) !void {
262262 token_tags [parse_error .token ].symbol (),
263263 });
264264 },
265+ .extra_addrspace_qualifier = > {
266+ return stream .writeAll ("extra addrspace qualifier" );
267+ },
265268 .extra_align_qualifier = > {
266269 return stream .writeAll ("extra align qualifier" );
267270 },
@@ -1021,7 +1024,7 @@ pub fn lastToken(tree: Tree, node: Node.Index) TokenIndex {
10211024 },
10221025 .fn_proto_one = > {
10231026 const extra = tree .extraData (datas [n ].lhs , Node .FnProtoOne );
1024- // linksection, callconv, align can appear in any order, so we
1027+ // addrspace, linksection, callconv, align can appear in any order, so we
10251028 // find the last one here.
10261029 var max_node : Node.Index = datas [n ].rhs ;
10271030 var max_start = token_starts [main_tokens [max_node ]];
@@ -1034,6 +1037,14 @@ pub fn lastToken(tree: Tree, node: Node.Index) TokenIndex {
10341037 max_offset = 1 ; // for the rparen
10351038 }
10361039 }
1040+ if (extra .addrspace_expr != 0 ) {
1041+ const start = token_starts [main_tokens [extra .addrspace_expr ]];
1042+ if (start > max_start ) {
1043+ max_node = extra .addrspace_expr ;
1044+ max_start = start ;
1045+ max_offset = 1 ; // for the rparen
1046+ }
1047+ }
10371048 if (extra .section_expr != 0 ) {
10381049 const start = token_starts [main_tokens [extra .section_expr ]];
10391050 if (start > max_start ) {
@@ -1055,7 +1066,7 @@ pub fn lastToken(tree: Tree, node: Node.Index) TokenIndex {
10551066 },
10561067 .fn_proto = > {
10571068 const extra = tree .extraData (datas [n ].lhs , Node .FnProto );
1058- // linksection, callconv, align can appear in any order, so we
1069+ // addrspace, linksection, callconv, align can appear in any order, so we
10591070 // find the last one here.
10601071 var max_node : Node.Index = datas [n ].rhs ;
10611072 var max_start = token_starts [main_tokens [max_node ]];
@@ -1068,6 +1079,14 @@ pub fn lastToken(tree: Tree, node: Node.Index) TokenIndex {
10681079 max_offset = 1 ; // for the rparen
10691080 }
10701081 }
1082+ if (extra .addrspace_expr != 0 ) {
1083+ const start = token_starts [main_tokens [extra .addrspace_expr ]];
1084+ if (start > max_start ) {
1085+ max_node = extra .addrspace_expr ;
1086+ max_start = start ;
1087+ max_offset = 1 ; // for the rparen
1088+ }
1089+ }
10711090 if (extra .section_expr != 0 ) {
10721091 const start = token_starts [main_tokens [extra .section_expr ]];
10731092 if (start > max_start ) {
@@ -1138,6 +1157,7 @@ pub fn globalVarDecl(tree: Tree, node: Node.Index) full.VarDecl {
11381157 return tree .fullVarDecl (.{
11391158 .type_node = extra .type_node ,
11401159 .align_node = extra .align_node ,
1160+ .addrspace_node = extra .addrspace_node ,
11411161 .section_node = extra .section_node ,
11421162 .init_node = data .rhs ,
11431163 .mut_token = tree .nodes .items (.main_token )[node ],
@@ -1151,6 +1171,7 @@ pub fn localVarDecl(tree: Tree, node: Node.Index) full.VarDecl {
11511171 return tree .fullVarDecl (.{
11521172 .type_node = extra .type_node ,
11531173 .align_node = extra .align_node ,
1174+ .addrspace_node = 0 ,
11541175 .section_node = 0 ,
11551176 .init_node = data .rhs ,
11561177 .mut_token = tree .nodes .items (.main_token )[node ],
@@ -1163,6 +1184,7 @@ pub fn simpleVarDecl(tree: Tree, node: Node.Index) full.VarDecl {
11631184 return tree .fullVarDecl (.{
11641185 .type_node = data .lhs ,
11651186 .align_node = 0 ,
1187+ .addrspace_node = 0 ,
11661188 .section_node = 0 ,
11671189 .init_node = data .rhs ,
11681190 .mut_token = tree .nodes .items (.main_token )[node ],
@@ -1175,6 +1197,7 @@ pub fn alignedVarDecl(tree: Tree, node: Node.Index) full.VarDecl {
11751197 return tree .fullVarDecl (.{
11761198 .type_node = 0 ,
11771199 .align_node = data .lhs ,
1200+ .addrspace_node = 0 ,
11781201 .section_node = 0 ,
11791202 .init_node = data .rhs ,
11801203 .mut_token = tree .nodes .items (.main_token )[node ],
@@ -1249,6 +1272,7 @@ pub fn fnProtoSimple(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.
12491272 .return_type = data .rhs ,
12501273 .params = params ,
12511274 .align_expr = 0 ,
1275+ .addrspace_expr = 0 ,
12521276 .section_expr = 0 ,
12531277 .callconv_expr = 0 ,
12541278 });
@@ -1265,6 +1289,7 @@ pub fn fnProtoMulti(tree: Tree, node: Node.Index) full.FnProto {
12651289 .return_type = data .rhs ,
12661290 .params = params ,
12671291 .align_expr = 0 ,
1292+ .addrspace_expr = 0 ,
12681293 .section_expr = 0 ,
12691294 .callconv_expr = 0 ,
12701295 });
@@ -1282,6 +1307,7 @@ pub fn fnProtoOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.FnP
12821307 .return_type = data .rhs ,
12831308 .params = params ,
12841309 .align_expr = extra .align_expr ,
1310+ .addrspace_expr = extra .addrspace_expr ,
12851311 .section_expr = extra .section_expr ,
12861312 .callconv_expr = extra .callconv_expr ,
12871313 });
@@ -1298,6 +1324,7 @@ pub fn fnProto(tree: Tree, node: Node.Index) full.FnProto {
12981324 .return_type = data .rhs ,
12991325 .params = params ,
13001326 .align_expr = extra .align_expr ,
1327+ .addrspace_expr = extra .addrspace_expr ,
13011328 .section_expr = extra .section_expr ,
13021329 .callconv_expr = extra .callconv_expr ,
13031330 });
@@ -1453,6 +1480,7 @@ pub fn ptrTypeAligned(tree: Tree, node: Node.Index) full.PtrType {
14531480 return tree .fullPtrType (.{
14541481 .main_token = tree .nodes .items (.main_token )[node ],
14551482 .align_node = data .lhs ,
1483+ .addrspace_node = 0 ,
14561484 .sentinel = 0 ,
14571485 .bit_range_start = 0 ,
14581486 .bit_range_end = 0 ,
@@ -1466,6 +1494,7 @@ pub fn ptrTypeSentinel(tree: Tree, node: Node.Index) full.PtrType {
14661494 return tree .fullPtrType (.{
14671495 .main_token = tree .nodes .items (.main_token )[node ],
14681496 .align_node = 0 ,
1497+ .addrspace_node = 0 ,
14691498 .sentinel = data .lhs ,
14701499 .bit_range_start = 0 ,
14711500 .bit_range_end = 0 ,
@@ -1480,6 +1509,7 @@ pub fn ptrType(tree: Tree, node: Node.Index) full.PtrType {
14801509 return tree .fullPtrType (.{
14811510 .main_token = tree .nodes .items (.main_token )[node ],
14821511 .align_node = extra .align_node ,
1512+ .addrspace_node = extra .addrspace_node ,
14831513 .sentinel = extra .sentinel ,
14841514 .bit_range_start = 0 ,
14851515 .bit_range_end = 0 ,
@@ -1494,6 +1524,7 @@ pub fn ptrTypeBitRange(tree: Tree, node: Node.Index) full.PtrType {
14941524 return tree .fullPtrType (.{
14951525 .main_token = tree .nodes .items (.main_token )[node ],
14961526 .align_node = extra .align_node ,
1527+ .addrspace_node = extra .addrspace_node ,
14971528 .sentinel = extra .sentinel ,
14981529 .bit_range_start = extra .bit_range_start ,
14991530 .bit_range_end = extra .bit_range_end ,
@@ -2063,6 +2094,7 @@ pub const full = struct {
20632094 mut_token : TokenIndex ,
20642095 type_node : Node.Index ,
20652096 align_node : Node.Index ,
2097+ addrspace_node : Node.Index ,
20662098 section_node : Node.Index ,
20672099 init_node : Node.Index ,
20682100 };
@@ -2130,6 +2162,7 @@ pub const full = struct {
21302162 return_type : Node.Index ,
21312163 params : []const Node.Index ,
21322164 align_expr : Node.Index ,
2165+ addrspace_expr : Node.Index ,
21332166 section_expr : Node.Index ,
21342167 callconv_expr : Node.Index ,
21352168 };
@@ -2288,6 +2321,7 @@ pub const full = struct {
22882321 pub const Components = struct {
22892322 main_token : TokenIndex ,
22902323 align_node : Node.Index ,
2324+ addrspace_node : Node.Index ,
22912325 sentinel : Node.Index ,
22922326 bit_range_start : Node.Index ,
22932327 bit_range_end : Node.Index ,
@@ -2397,6 +2431,7 @@ pub const Error = struct {
23972431 expected_var_decl_or_fn ,
23982432 expected_loop_payload ,
23992433 expected_container ,
2434+ extra_addrspace_qualifier ,
24002435 extra_align_qualifier ,
24012436 extra_allowzero_qualifier ,
24022437 extra_const_qualifier ,
@@ -2723,13 +2758,13 @@ pub const Node = struct {
27232758 /// main_token is the `fn` keyword.
27242759 /// extern function declarations use this tag.
27252760 fn_proto_multi ,
2726- /// `fn(a: b) rhs linksection (e) callconv(f )`. `FnProtoOne[lhs]`.
2761+ /// `fn(a: b) rhs addrspace (e) linksection(f) callconv(g )`. `FnProtoOne[lhs]`.
27272762 /// zero or one parameters.
27282763 /// anytype and ... parameters are omitted from the AST tree.
27292764 /// main_token is the `fn` keyword.
27302765 /// extern function declarations use this tag.
27312766 fn_proto_one ,
2732- /// `fn(a: b, c: d) rhs linksection (e) callconv(f )`. `FnProto[lhs]`.
2767+ /// `fn(a: b, c: d) rhs addrspace (e) linksection(f) callconv(g )`. `FnProto[lhs]`.
27332768 /// anytype and ... parameters are omitted from the AST tree.
27342769 /// main_token is the `fn` keyword.
27352770 /// extern function declarations use this tag.
@@ -2893,11 +2928,13 @@ pub const Node = struct {
28932928 pub const PtrType = struct {
28942929 sentinel : Index ,
28952930 align_node : Index ,
2931+ addrspace_node : Index ,
28962932 };
28972933
28982934 pub const PtrTypeBitRange = struct {
28992935 sentinel : Index ,
29002936 align_node : Index ,
2937+ addrspace_node : Index ,
29012938 bit_range_start : Index ,
29022939 bit_range_end : Index ,
29032940 };
@@ -2920,8 +2957,13 @@ pub const Node = struct {
29202957 };
29212958
29222959 pub const GlobalVarDecl = struct {
2960+ /// Populated if there is an explicit type ascription.
29232961 type_node : Index ,
2962+ /// Populated if align(A) is present.
29242963 align_node : Index ,
2964+ /// Populated if linksection(A) is present.
2965+ addrspace_node : Index ,
2966+ /// Populated if addrspace(A) is present.
29252967 section_node : Index ,
29262968 };
29272969
@@ -2954,6 +2996,8 @@ pub const Node = struct {
29542996 /// Populated if align(A) is present.
29552997 align_expr : Index ,
29562998 /// Populated if linksection(A) is present.
2999+ addrspace_expr : Index ,
3000+ /// Populated if addrspace(A) is present.
29573001 section_expr : Index ,
29583002 /// Populated if callconv(A) is present.
29593003 callconv_expr : Index ,
@@ -2964,6 +3008,8 @@ pub const Node = struct {
29643008 params_end : Index ,
29653009 /// Populated if align(A) is present.
29663010 align_expr : Index ,
3011+ /// Populated if addrspace(A) is present.
3012+ addrspace_expr : Index ,
29673013 /// Populated if linksection(A) is present.
29683014 section_expr : Index ,
29693015 /// Populated if callconv(A) is present.
0 commit comments