authorgravatar for gbell12907@gmail.comCMDRZero <gbell12907@gmail.com> 2026-07-13 15:47:13-05:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-10-22 12:21:43+02:00
log12ead9415ca1dfb15803c46d4598141daee314ba
tree321215ab74bd51b648120812f39452275c666657
parent64e4f9db8fa6fc47b0a2ef3143edacf472fb8c48

Update `grammar.peg` to conform to new Partial Operator Ordering


2 files changed, 521 insertions(+), 85 deletions(-)

doc/langref/grammar.peg+44-18
......@@ -127,21 +127,34 @@ AssignExpr <- Expr (AssignOp Expr / (COMMA Expr)+ EQUAL Expr / !AssignOp !COMMA)
127127
128128SingleAssignExpr <- Expr (AssignOp Expr / !AssignOp)
129129
130Expr <- BoolOrExpr
130Expr <- PrefixExpr (OrElseExpr / CatchExpr / BoolExpr)
131131
132BoolOrExpr <- BoolAndExpr (OrOp BoolAndExpr)* !OrOp
132OrElseExpr <- (OrElseOp PrefixExpr)+ !RecoveryNonmixingOp
133CatchExpr <- (CatchOp PrefixExpr)+ !RecoveryNonmixingOp
134RecoveryNonmixingOp <- ControlOp / CompareOp / BitwiseNonmixingOp
135ControlOp <- OrElseOp / CatchOp / AndOp / OrOp
133136
134BoolAndExpr <- CompareExpr (AndOp CompareExpr)* !AndOp
137BoolExpr <- CompareExpr (BoolAndExpr / BoolOrExpr / !ControlOp)
138BoolAndExpr <- (AndOp PrefixExpr CompareExpr)+ !ControlOp
139BoolOrExpr <- (OrOp PrefixExpr CompareExpr)+ !ControlOp
135140
136CompareExpr <- BitwiseExpr (CompareOp BitwiseExpr)? !CompareOp
141CompareExpr <- CompareOperand (CompareOp PrefixExpr CompareOperand)? !(CompareOp / OrElseOp / CatchOp)
142CompareOperand
143 <- (BitwiseOrOp PrefixExpr)+ !BitwiseNonmixingOp
144 / (BitwiseAndOp PrefixExpr)+ !BitwiseNonmixingOp
145 / (BitwiseXorOp PrefixExpr)+ !BitwiseNonmixingOp
146 / BitShiftOp PrefixExpr !BitwiseNonmixingOp
147 / !BitOp AdditionExpr
137148
138BitwiseExpr <- BitShiftExpr (BitwiseOp BitShiftExpr)* !BitwiseOp
149BitOp <- BitwiseOrOp / BitwiseAndOp / BitwiseXorOp / BitShiftOp
150BitwiseNonmixingOp <- MultiplyNonmixingOp / AdditionOp
139151
140BitShiftExpr <- AdditionExpr (BitShiftOp AdditionExpr)* !BitShiftOp
152AdditionExpr <- MulOrModExpr (AdditionOp PrefixExpr MulOrModExpr)* !(AdditionOp / BitOp / OrElseOp / CatchOp)
141153
142AdditionExpr <- MultiplyExpr (AdditionOp MultiplyExpr)* !AdditionOp
143
144MultiplyExpr <- PrefixExpr (MultiplyOp PrefixExpr)* !MultiplyOp
154MulOrModExpr <- ModExpr / !ModOp MultiplyExpr
155ModExpr <- ModOp PrefixExpr !MultiplyNonmixingOp
156MultiplyExpr <- (MultiplyOp PrefixExpr)* !MultiplyNonmixingOp
157MultiplyNonmixingOp <- MultiplyOp / ModOp / BitOp / OrElseOp / CatchOp
145158
146159PrefixExpr <- PrefixOp* !PrefixOp PrimaryExpr
147160
......@@ -323,15 +336,26 @@ CompareOpTok
323336 / LARROWEQUAL
324337 / RARROWEQUAL
325338
326BitwiseOp <- pre_op_white BitwiseOpTok post_op_white
327 / !pre_op_white BitwiseOpTok !post_op_white
328 / pre_op_white KEYWORD_catch post_op_white Payload?
329 / !pre_op_white KEYWORD_catch !post_op_white Payload?
330BitwiseOpTok
339BitwiseAndOp <- pre_op_white BitwiseAndOpTok post_op_white
340 / !pre_op_white BitwiseAndOpTok !post_op_white
341BitwiseAndOpTok
331342 <- AMPERSAND ![&]
332 / CARET
333 / PIPE
334 / KEYWORD_orelse
343
344BitwiseOrOp <- pre_op_white BitwiseOrOpTok post_op_white
345 / !pre_op_white BitwiseOrOpTok !post_op_white
346BitwiseOrOpTok
347 <- PIPE
348
349BitwiseXorOp <- pre_op_white BitwiseXorOpTok post_op_white
350 / !pre_op_white BitwiseXorOpTok !post_op_white
351BitwiseXorOpTok
352 <- CARET
353
354CatchOp <- pre_op_white KEYWORD_catch post_op_white Payload?
355 / !pre_op_white KEYWORD_catch !post_op_white Payload?
356
357OrElseOp <- pre_op_white KEYWORD_orelse post_op_white
358 / !pre_op_white KEYWORD_orelse !post_op_white
335359
336360BitShiftOp <- pre_op_white BitShiftOpTok post_op_white
337361 / !pre_op_white BitShiftOpTok !post_op_white
......@@ -357,10 +381,12 @@ MultiplyOpTok
357381 <- PIPE2
358382 / ASTERISK
359383 / SLASH
360 / PERCENT
361384 / ASTERISKPERCENT
362385 / ASTERISKPIPE
363386
387ModOp <- pre_op_white PERCENT post_op_white
388 / !pre_op_white PERCENT !post_op_white
389
364390PrefixOp
365391 <- EXCLAMATIONMARK
366392 / MINUS
lib/std/zig/parser_generated_oracle.zig+477-67
......@@ -42,13 +42,22 @@ const Def = enum {
4242 defAssignExpr,
4343 defSingleAssignExpr,
4444 defExpr,
45 defBoolOrExpr,
45 defOrElseExpr,
46 defCatchExpr,
47 defRecoveryNonmixingOp,
48 defControlOp,
49 defBoolExpr,
4650 defBoolAndExpr,
51 defBoolOrExpr,
4752 defCompareExpr,
48 defBitwiseExpr,
49 defBitShiftExpr,
53 defCompareOperand,
54 defBitOp,
55 defBitwiseNonmixingOp,
5056 defAdditionExpr,
57 defMulOrModExpr,
58 defModExpr,
5159 defMultiplyExpr,
60 defMultiplyNonmixingOp,
5261 defPrefixExpr,
5362 defPrimaryExpr,
5463 defIfExpr,
......@@ -103,14 +112,21 @@ const Def = enum {
103112 defAndOp,
104113 defCompareOp,
105114 defCompareOpTok,
106 defBitwiseOp,
107 defBitwiseOpTok,
115 defBitwiseAndOp,
116 defBitwiseAndOpTok,
117 defBitwiseOrOp,
118 defBitwiseOrOpTok,
119 defBitwiseXorOp,
120 defBitwiseXorOpTok,
121 defCatchOp,
122 defOrElseOp,
108123 defBitShiftOp,
109124 defBitShiftOpTok,
110125 defAdditionOp,
111126 defAdditionOpTok,
112127 defMultiplyOp,
113128 defMultiplyOpTok,
129 defModOp,
114130 defPrefixOp,
115131 defPrefixTypeOp,
116132 defPtrMods,
......@@ -290,7 +306,7 @@ const Def = enum {
290306const Parser = struct {
291307 source: []const u8,
292308 i: usize,
293 depths: [272]u8,
309 depths: [288]u8,
294310 pub fn parseRoot(p: *Parser) Error!bool {
295311 const def_index = @backingInt(Def.defRoot);
296312 if (p.depths[def_index] > max_depth) return error.MaxDepth;
......@@ -964,33 +980,44 @@ const Parser = struct {
964980 defer p.depths[def_index] -= 1;
965981 return blk_0: {
966982 const pos_0 = p.i;
967 if (try p.parseBoolOrExpr()) break :blk_0 true;
983 if (try p.parsePrefixExpr() and blk_2: {
984 const pos_2 = p.i;
985 if (try p.parseOrElseExpr()) break :blk_2 true;
986 p.i = pos_2;
987 if (try p.parseCatchExpr()) break :blk_2 true;
988 p.i = pos_2;
989 if (try p.parseBoolExpr()) break :blk_2 true;
990 p.i = pos_2;
991 break :blk_2 false;
992 }) break :blk_0 true;
968993 p.i = pos_0;
969994 break :blk_0 false;
970995 };
971996 }
972 pub fn parseBoolOrExpr(p: *Parser) Error!bool {
973 const def_index = @backingInt(Def.defBoolOrExpr);
997 pub fn parseOrElseExpr(p: *Parser) Error!bool {
998 const def_index = @backingInt(Def.defOrElseExpr);
974999 if (p.depths[def_index] > max_depth) return error.MaxDepth;
9751000 p.depths[def_index] += 1;
9761001 defer p.depths[def_index] -= 1;
9771002 return blk_0: {
9781003 const pos_0 = p.i;
979 if (try p.parseBoolAndExpr() and blk_1: {
1004 if (blk_1: {
1005 var match_1 = false;
9801006 var i_1: usize = 0;
9811007 while (blk_3: {
9821008 const pos_3 = p.i;
983 if (try p.parseOrOp() and try p.parseBoolAndExpr()) break :blk_3 true;
1009 if (try p.parseOrElseOp() and try p.parsePrefixExpr()) break :blk_3 true;
9841010 p.i = pos_3;
9851011 break :blk_3 false;
9861012 }) {
1013 match_1 = true;
9871014 if (i_1 > max_depth) return error.MaxDepth;
9881015 i_1 += 1;
9891016 }
990 break :blk_1 true;
1017 break :blk_1 match_1;
9911018 } and blk_1: {
9921019 const pos_1 = p.i;
993 const match_1 = try p.parseOrOp();
1020 const match_1 = try p.parseRecoveryNonmixingOp();
9941021 p.i = pos_1;
9951022 break :blk_1 !match_1;
9961023 }) break :blk_0 true;
......@@ -998,28 +1025,30 @@ const Parser = struct {
9981025 break :blk_0 false;
9991026 };
10001027 }
1001 pub fn parseBoolAndExpr(p: *Parser) Error!bool {
1002 const def_index = @backingInt(Def.defBoolAndExpr);
1028 pub fn parseCatchExpr(p: *Parser) Error!bool {
1029 const def_index = @backingInt(Def.defCatchExpr);
10031030 if (p.depths[def_index] > max_depth) return error.MaxDepth;
10041031 p.depths[def_index] += 1;
10051032 defer p.depths[def_index] -= 1;
10061033 return blk_0: {
10071034 const pos_0 = p.i;
1008 if (try p.parseCompareExpr() and blk_1: {
1035 if (blk_1: {
1036 var match_1 = false;
10091037 var i_1: usize = 0;
10101038 while (blk_3: {
10111039 const pos_3 = p.i;
1012 if (try p.parseAndOp() and try p.parseCompareExpr()) break :blk_3 true;
1040 if (try p.parseCatchOp() and try p.parsePrefixExpr()) break :blk_3 true;
10131041 p.i = pos_3;
10141042 break :blk_3 false;
10151043 }) {
1044 match_1 = true;
10161045 if (i_1 > max_depth) return error.MaxDepth;
10171046 i_1 += 1;
10181047 }
1019 break :blk_1 true;
1048 break :blk_1 match_1;
10201049 } and blk_1: {
10211050 const pos_1 = p.i;
1022 const match_1 = try p.parseAndOp();
1051 const match_1 = try p.parseRecoveryNonmixingOp();
10231052 p.i = pos_1;
10241053 break :blk_1 !match_1;
10251054 }) break :blk_0 true;
......@@ -1027,21 +1056,90 @@ const Parser = struct {
10271056 break :blk_0 false;
10281057 };
10291058 }
1030 pub fn parseCompareExpr(p: *Parser) Error!bool {
1031 const def_index = @backingInt(Def.defCompareExpr);
1059 pub fn parseRecoveryNonmixingOp(p: *Parser) Error!bool {
1060 const def_index = @backingInt(Def.defRecoveryNonmixingOp);
10321061 if (p.depths[def_index] > max_depth) return error.MaxDepth;
10331062 p.depths[def_index] += 1;
10341063 defer p.depths[def_index] -= 1;
10351064 return blk_0: {
10361065 const pos_0 = p.i;
1037 if (try p.parseBitwiseExpr() and (blk_3: {
1038 const pos_3 = p.i;
1039 if (try p.parseCompareOp() and try p.parseBitwiseExpr()) break :blk_3 true;
1040 p.i = pos_3;
1041 break :blk_3 false;
1042 } or true) and blk_1: {
1066 if (try p.parseControlOp()) break :blk_0 true;
1067 p.i = pos_0;
1068 if (try p.parseCompareOp()) break :blk_0 true;
1069 p.i = pos_0;
1070 if (try p.parseBitwiseNonmixingOp()) break :blk_0 true;
1071 p.i = pos_0;
1072 break :blk_0 false;
1073 };
1074 }
1075 pub fn parseControlOp(p: *Parser) Error!bool {
1076 const def_index = @backingInt(Def.defControlOp);
1077 if (p.depths[def_index] > max_depth) return error.MaxDepth;
1078 p.depths[def_index] += 1;
1079 defer p.depths[def_index] -= 1;
1080 return blk_0: {
1081 const pos_0 = p.i;
1082 if (try p.parseOrElseOp()) break :blk_0 true;
1083 p.i = pos_0;
1084 if (try p.parseCatchOp()) break :blk_0 true;
1085 p.i = pos_0;
1086 if (try p.parseAndOp()) break :blk_0 true;
1087 p.i = pos_0;
1088 if (try p.parseOrOp()) break :blk_0 true;
1089 p.i = pos_0;
1090 break :blk_0 false;
1091 };
1092 }
1093 pub fn parseBoolExpr(p: *Parser) Error!bool {
1094 const def_index = @backingInt(Def.defBoolExpr);
1095 if (p.depths[def_index] > max_depth) return error.MaxDepth;
1096 p.depths[def_index] += 1;
1097 defer p.depths[def_index] -= 1;
1098 return blk_0: {
1099 const pos_0 = p.i;
1100 if (try p.parseCompareExpr() and blk_2: {
1101 const pos_2 = p.i;
1102 if (try p.parseBoolAndExpr()) break :blk_2 true;
1103 p.i = pos_2;
1104 if (try p.parseBoolOrExpr()) break :blk_2 true;
1105 p.i = pos_2;
1106 if (blk_3: {
1107 const pos_3 = p.i;
1108 const match_3 = try p.parseControlOp();
1109 p.i = pos_3;
1110 break :blk_3 !match_3;
1111 }) break :blk_2 true;
1112 p.i = pos_2;
1113 break :blk_2 false;
1114 }) break :blk_0 true;
1115 p.i = pos_0;
1116 break :blk_0 false;
1117 };
1118 }
1119 pub fn parseBoolAndExpr(p: *Parser) Error!bool {
1120 const def_index = @backingInt(Def.defBoolAndExpr);
1121 if (p.depths[def_index] > max_depth) return error.MaxDepth;
1122 p.depths[def_index] += 1;
1123 defer p.depths[def_index] -= 1;
1124 return blk_0: {
1125 const pos_0 = p.i;
1126 if (blk_1: {
1127 var match_1 = false;
1128 var i_1: usize = 0;
1129 while (blk_3: {
1130 const pos_3 = p.i;
1131 if (try p.parseAndOp() and try p.parsePrefixExpr() and try p.parseCompareExpr()) break :blk_3 true;
1132 p.i = pos_3;
1133 break :blk_3 false;
1134 }) {
1135 match_1 = true;
1136 if (i_1 > max_depth) return error.MaxDepth;
1137 i_1 += 1;
1138 }
1139 break :blk_1 match_1;
1140 } and blk_1: {
10431141 const pos_1 = p.i;
1044 const match_1 = try p.parseCompareOp();
1142 const match_1 = try p.parseControlOp();
10451143 p.i = pos_1;
10461144 break :blk_1 !match_1;
10471145 }) break :blk_0 true;
......@@ -1049,28 +1147,30 @@ const Parser = struct {
10491147 break :blk_0 false;
10501148 };
10511149 }
1052 pub fn parseBitwiseExpr(p: *Parser) Error!bool {
1053 const def_index = @backingInt(Def.defBitwiseExpr);
1150 pub fn parseBoolOrExpr(p: *Parser) Error!bool {
1151 const def_index = @backingInt(Def.defBoolOrExpr);
10541152 if (p.depths[def_index] > max_depth) return error.MaxDepth;
10551153 p.depths[def_index] += 1;
10561154 defer p.depths[def_index] -= 1;
10571155 return blk_0: {
10581156 const pos_0 = p.i;
1059 if (try p.parseBitShiftExpr() and blk_1: {
1157 if (blk_1: {
1158 var match_1 = false;
10601159 var i_1: usize = 0;
10611160 while (blk_3: {
10621161 const pos_3 = p.i;
1063 if (try p.parseBitwiseOp() and try p.parseBitShiftExpr()) break :blk_3 true;
1162 if (try p.parseOrOp() and try p.parsePrefixExpr() and try p.parseCompareExpr()) break :blk_3 true;
10641163 p.i = pos_3;
10651164 break :blk_3 false;
10661165 }) {
1166 match_1 = true;
10671167 if (i_1 > max_depth) return error.MaxDepth;
10681168 i_1 += 1;
10691169 }
1070 break :blk_1 true;
1170 break :blk_1 match_1;
10711171 } and blk_1: {
10721172 const pos_1 = p.i;
1073 const match_1 = try p.parseBitwiseOp();
1173 const match_1 = try p.parseControlOp();
10741174 p.i = pos_1;
10751175 break :blk_1 !match_1;
10761176 }) break :blk_0 true;
......@@ -1078,32 +1178,153 @@ const Parser = struct {
10781178 break :blk_0 false;
10791179 };
10801180 }
1081 pub fn parseBitShiftExpr(p: *Parser) Error!bool {
1082 const def_index = @backingInt(Def.defBitShiftExpr);
1181 pub fn parseCompareExpr(p: *Parser) Error!bool {
1182 const def_index = @backingInt(Def.defCompareExpr);
10831183 if (p.depths[def_index] > max_depth) return error.MaxDepth;
10841184 p.depths[def_index] += 1;
10851185 defer p.depths[def_index] -= 1;
10861186 return blk_0: {
10871187 const pos_0 = p.i;
1088 if (try p.parseAdditionExpr() and blk_1: {
1188 if (try p.parseCompareOperand() and (blk_3: {
1189 const pos_3 = p.i;
1190 if (try p.parseCompareOp() and try p.parsePrefixExpr() and try p.parseCompareOperand()) break :blk_3 true;
1191 p.i = pos_3;
1192 break :blk_3 false;
1193 } or true) and blk_1: {
1194 const pos_1 = p.i;
1195 const match_1 = blk_3: {
1196 const pos_3 = p.i;
1197 if (try p.parseCompareOp()) break :blk_3 true;
1198 p.i = pos_3;
1199 if (try p.parseOrElseOp()) break :blk_3 true;
1200 p.i = pos_3;
1201 if (try p.parseCatchOp()) break :blk_3 true;
1202 p.i = pos_3;
1203 break :blk_3 false;
1204 };
1205 p.i = pos_1;
1206 break :blk_1 !match_1;
1207 }) break :blk_0 true;
1208 p.i = pos_0;
1209 break :blk_0 false;
1210 };
1211 }
1212 pub fn parseCompareOperand(p: *Parser) Error!bool {
1213 const def_index = @backingInt(Def.defCompareOperand);
1214 if (p.depths[def_index] > max_depth) return error.MaxDepth;
1215 p.depths[def_index] += 1;
1216 defer p.depths[def_index] -= 1;
1217 return blk_0: {
1218 const pos_0 = p.i;
1219 if (blk_1: {
1220 var match_1 = false;
10891221 var i_1: usize = 0;
10901222 while (blk_3: {
10911223 const pos_3 = p.i;
1092 if (try p.parseBitShiftOp() and try p.parseAdditionExpr()) break :blk_3 true;
1224 if (try p.parseBitwiseOrOp() and try p.parsePrefixExpr()) break :blk_3 true;
10931225 p.i = pos_3;
10941226 break :blk_3 false;
10951227 }) {
1228 match_1 = true;
10961229 if (i_1 > max_depth) return error.MaxDepth;
10971230 i_1 += 1;
10981231 }
1099 break :blk_1 true;
1232 break :blk_1 match_1;
1233 } and blk_1: {
1234 const pos_1 = p.i;
1235 const match_1 = try p.parseBitwiseNonmixingOp();
1236 p.i = pos_1;
1237 break :blk_1 !match_1;
1238 }) break :blk_0 true;
1239 p.i = pos_0;
1240 if (blk_1: {
1241 var match_1 = false;
1242 var i_1: usize = 0;
1243 while (blk_3: {
1244 const pos_3 = p.i;
1245 if (try p.parseBitwiseAndOp() and try p.parsePrefixExpr()) break :blk_3 true;
1246 p.i = pos_3;
1247 break :blk_3 false;
1248 }) {
1249 match_1 = true;
1250 if (i_1 > max_depth) return error.MaxDepth;
1251 i_1 += 1;
1252 }
1253 break :blk_1 match_1;
1254 } and blk_1: {
1255 const pos_1 = p.i;
1256 const match_1 = try p.parseBitwiseNonmixingOp();
1257 p.i = pos_1;
1258 break :blk_1 !match_1;
1259 }) break :blk_0 true;
1260 p.i = pos_0;
1261 if (blk_1: {
1262 var match_1 = false;
1263 var i_1: usize = 0;
1264 while (blk_3: {
1265 const pos_3 = p.i;
1266 if (try p.parseBitwiseXorOp() and try p.parsePrefixExpr()) break :blk_3 true;
1267 p.i = pos_3;
1268 break :blk_3 false;
1269 }) {
1270 match_1 = true;
1271 if (i_1 > max_depth) return error.MaxDepth;
1272 i_1 += 1;
1273 }
1274 break :blk_1 match_1;
11001275 } and blk_1: {
11011276 const pos_1 = p.i;
1102 const match_1 = try p.parseBitShiftOp();
1277 const match_1 = try p.parseBitwiseNonmixingOp();
11031278 p.i = pos_1;
11041279 break :blk_1 !match_1;
11051280 }) break :blk_0 true;
11061281 p.i = pos_0;
1282 if (try p.parseBitShiftOp() and try p.parsePrefixExpr() and blk_1: {
1283 const pos_1 = p.i;
1284 const match_1 = try p.parseBitwiseNonmixingOp();
1285 p.i = pos_1;
1286 break :blk_1 !match_1;
1287 }) break :blk_0 true;
1288 p.i = pos_0;
1289 if (blk_1: {
1290 const pos_1 = p.i;
1291 const match_1 = try p.parseBitOp();
1292 p.i = pos_1;
1293 break :blk_1 !match_1;
1294 } and try p.parseAdditionExpr()) break :blk_0 true;
1295 p.i = pos_0;
1296 break :blk_0 false;
1297 };
1298 }
1299 pub fn parseBitOp(p: *Parser) Error!bool {
1300 const def_index = @backingInt(Def.defBitOp);
1301 if (p.depths[def_index] > max_depth) return error.MaxDepth;
1302 p.depths[def_index] += 1;
1303 defer p.depths[def_index] -= 1;
1304 return blk_0: {
1305 const pos_0 = p.i;
1306 if (try p.parseBitwiseOrOp()) break :blk_0 true;
1307 p.i = pos_0;
1308 if (try p.parseBitwiseAndOp()) break :blk_0 true;
1309 p.i = pos_0;
1310 if (try p.parseBitwiseXorOp()) break :blk_0 true;
1311 p.i = pos_0;
1312 if (try p.parseBitShiftOp()) break :blk_0 true;
1313 p.i = pos_0;
1314 break :blk_0 false;
1315 };
1316 }
1317 pub fn parseBitwiseNonmixingOp(p: *Parser) Error!bool {
1318 const def_index = @backingInt(Def.defBitwiseNonmixingOp);
1319 if (p.depths[def_index] > max_depth) return error.MaxDepth;
1320 p.depths[def_index] += 1;
1321 defer p.depths[def_index] -= 1;
1322 return blk_0: {
1323 const pos_0 = p.i;
1324 if (try p.parseMultiplyNonmixingOp()) break :blk_0 true;
1325 p.i = pos_0;
1326 if (try p.parseAdditionOp()) break :blk_0 true;
1327 p.i = pos_0;
11071328 break :blk_0 false;
11081329 };
11091330 }
......@@ -1114,11 +1335,11 @@ const Parser = struct {
11141335 defer p.depths[def_index] -= 1;
11151336 return blk_0: {
11161337 const pos_0 = p.i;
1117 if (try p.parseMultiplyExpr() and blk_1: {
1338 if (try p.parseMulOrModExpr() and blk_1: {
11181339 var i_1: usize = 0;
11191340 while (blk_3: {
11201341 const pos_3 = p.i;
1121 if (try p.parseAdditionOp() and try p.parseMultiplyExpr()) break :blk_3 true;
1342 if (try p.parseAdditionOp() and try p.parsePrefixExpr() and try p.parseMulOrModExpr()) break :blk_3 true;
11221343 p.i = pos_3;
11231344 break :blk_3 false;
11241345 }) {
......@@ -1128,7 +1349,54 @@ const Parser = struct {
11281349 break :blk_1 true;
11291350 } and blk_1: {
11301351 const pos_1 = p.i;
1131 const match_1 = try p.parseAdditionOp();
1352 const match_1 = blk_3: {
1353 const pos_3 = p.i;
1354 if (try p.parseAdditionOp()) break :blk_3 true;
1355 p.i = pos_3;
1356 if (try p.parseBitOp()) break :blk_3 true;
1357 p.i = pos_3;
1358 if (try p.parseOrElseOp()) break :blk_3 true;
1359 p.i = pos_3;
1360 if (try p.parseCatchOp()) break :blk_3 true;
1361 p.i = pos_3;
1362 break :blk_3 false;
1363 };
1364 p.i = pos_1;
1365 break :blk_1 !match_1;
1366 }) break :blk_0 true;
1367 p.i = pos_0;
1368 break :blk_0 false;
1369 };
1370 }
1371 pub fn parseMulOrModExpr(p: *Parser) Error!bool {
1372 const def_index = @backingInt(Def.defMulOrModExpr);
1373 if (p.depths[def_index] > max_depth) return error.MaxDepth;
1374 p.depths[def_index] += 1;
1375 defer p.depths[def_index] -= 1;
1376 return blk_0: {
1377 const pos_0 = p.i;
1378 if (try p.parseModExpr()) break :blk_0 true;
1379 p.i = pos_0;
1380 if (blk_1: {
1381 const pos_1 = p.i;
1382 const match_1 = try p.parseModOp();
1383 p.i = pos_1;
1384 break :blk_1 !match_1;
1385 } and try p.parseMultiplyExpr()) break :blk_0 true;
1386 p.i = pos_0;
1387 break :blk_0 false;
1388 };
1389 }
1390 pub fn parseModExpr(p: *Parser) Error!bool {
1391 const def_index = @backingInt(Def.defModExpr);
1392 if (p.depths[def_index] > max_depth) return error.MaxDepth;
1393 p.depths[def_index] += 1;
1394 defer p.depths[def_index] -= 1;
1395 return blk_0: {
1396 const pos_0 = p.i;
1397 if (try p.parseModOp() and try p.parsePrefixExpr() and blk_1: {
1398 const pos_1 = p.i;
1399 const match_1 = try p.parseMultiplyNonmixingOp();
11321400 p.i = pos_1;
11331401 break :blk_1 !match_1;
11341402 }) break :blk_0 true;
......@@ -1143,7 +1411,7 @@ const Parser = struct {
11431411 defer p.depths[def_index] -= 1;
11441412 return blk_0: {
11451413 const pos_0 = p.i;
1146 if (try p.parsePrefixExpr() and blk_1: {
1414 if (blk_1: {
11471415 var i_1: usize = 0;
11481416 while (blk_3: {
11491417 const pos_3 = p.i;
......@@ -1157,7 +1425,7 @@ const Parser = struct {
11571425 break :blk_1 true;
11581426 } and blk_1: {
11591427 const pos_1 = p.i;
1160 const match_1 = try p.parseMultiplyOp();
1428 const match_1 = try p.parseMultiplyNonmixingOp();
11611429 p.i = pos_1;
11621430 break :blk_1 !match_1;
11631431 }) break :blk_0 true;
......@@ -1165,6 +1433,26 @@ const Parser = struct {
11651433 break :blk_0 false;
11661434 };
11671435 }
1436 pub fn parseMultiplyNonmixingOp(p: *Parser) Error!bool {
1437 const def_index = @backingInt(Def.defMultiplyNonmixingOp);
1438 if (p.depths[def_index] > max_depth) return error.MaxDepth;
1439 p.depths[def_index] += 1;
1440 defer p.depths[def_index] -= 1;
1441 return blk_0: {
1442 const pos_0 = p.i;
1443 if (try p.parseMultiplyOp()) break :blk_0 true;
1444 p.i = pos_0;
1445 if (try p.parseModOp()) break :blk_0 true;
1446 p.i = pos_0;
1447 if (try p.parseBitOp()) break :blk_0 true;
1448 p.i = pos_0;
1449 if (try p.parseOrElseOp()) break :blk_0 true;
1450 p.i = pos_0;
1451 if (try p.parseCatchOp()) break :blk_0 true;
1452 p.i = pos_0;
1453 break :blk_0 false;
1454 };
1455 }
11681456 pub fn parsePrefixExpr(p: *Parser) Error!bool {
11691457 const def_index = @backingInt(Def.defPrefixExpr);
11701458 if (p.depths[def_index] > max_depth) return error.MaxDepth;
......@@ -2259,70 +2547,170 @@ const Parser = struct {
22592547 break :blk_0 false;
22602548 };
22612549 }
2262 pub fn parseBitwiseOp(p: *Parser) Error!bool {
2263 const def_index = @backingInt(Def.defBitwiseOp);
2550 pub fn parseBitwiseAndOp(p: *Parser) Error!bool {
2551 const def_index = @backingInt(Def.defBitwiseAndOp);
22642552 if (p.depths[def_index] > max_depth) return error.MaxDepth;
22652553 p.depths[def_index] += 1;
22662554 defer p.depths[def_index] -= 1;
22672555 return blk_0: {
22682556 const pos_0 = p.i;
2269 if (try p.parsepre_op_white() and try p.parseBitwiseOpTok() and try p.parsepost_op_white()) break :blk_0 true;
2557 if (try p.parsepre_op_white() and try p.parseBitwiseAndOpTok() and try p.parsepost_op_white()) break :blk_0 true;
22702558 p.i = pos_0;
22712559 if (blk_1: {
22722560 const pos_1 = p.i;
22732561 const match_1 = try p.parsepre_op_white();
22742562 p.i = pos_1;
22752563 break :blk_1 !match_1;
2276 } and try p.parseBitwiseOpTok() and blk_1: {
2564 } and try p.parseBitwiseAndOpTok() and blk_1: {
22772565 const pos_1 = p.i;
22782566 const match_1 = try p.parsepost_op_white();
22792567 p.i = pos_1;
22802568 break :blk_1 !match_1;
22812569 }) break :blk_0 true;
22822570 p.i = pos_0;
2283 if (try p.parsepre_op_white() and try p.parseKEYWORD_catch() and try p.parsepost_op_white() and (try p.parsePayload() or true)) break :blk_0 true;
2571 break :blk_0 false;
2572 };
2573 }
2574 pub fn parseBitwiseAndOpTok(p: *Parser) Error!bool {
2575 const def_index = @backingInt(Def.defBitwiseAndOpTok);
2576 if (p.depths[def_index] > max_depth) return error.MaxDepth;
2577 p.depths[def_index] += 1;
2578 defer p.depths[def_index] -= 1;
2579 return blk_0: {
2580 const pos_0 = p.i;
2581 if (try p.parseAMPERSAND() and blk_1: {
2582 const pos_1 = p.i;
2583 const match_1 = (p.i < p.source.len and switch (p.source[p.i]) {
2584 '&'...'&',
2585 => blk_2: {
2586 p.i += 1;
2587 break :blk_2 true;
2588 },
2589 else => false,
2590 });
2591 p.i = pos_1;
2592 break :blk_1 !match_1;
2593 }) break :blk_0 true;
2594 p.i = pos_0;
2595 break :blk_0 false;
2596 };
2597 }
2598 pub fn parseBitwiseOrOp(p: *Parser) Error!bool {
2599 const def_index = @backingInt(Def.defBitwiseOrOp);
2600 if (p.depths[def_index] > max_depth) return error.MaxDepth;
2601 p.depths[def_index] += 1;
2602 defer p.depths[def_index] -= 1;
2603 return blk_0: {
2604 const pos_0 = p.i;
2605 if (try p.parsepre_op_white() and try p.parseBitwiseOrOpTok() and try p.parsepost_op_white()) break :blk_0 true;
22842606 p.i = pos_0;
22852607 if (blk_1: {
22862608 const pos_1 = p.i;
22872609 const match_1 = try p.parsepre_op_white();
22882610 p.i = pos_1;
22892611 break :blk_1 !match_1;
2290 } and try p.parseKEYWORD_catch() and blk_1: {
2612 } and try p.parseBitwiseOrOpTok() and blk_1: {
22912613 const pos_1 = p.i;
22922614 const match_1 = try p.parsepost_op_white();
22932615 p.i = pos_1;
22942616 break :blk_1 !match_1;
2295 } and (try p.parsePayload() or true)) break :blk_0 true;
2617 }) break :blk_0 true;
22962618 p.i = pos_0;
22972619 break :blk_0 false;
22982620 };
22992621 }
2300 pub fn parseBitwiseOpTok(p: *Parser) Error!bool {
2301 const def_index = @backingInt(Def.defBitwiseOpTok);
2622 pub fn parseBitwiseOrOpTok(p: *Parser) Error!bool {
2623 const def_index = @backingInt(Def.defBitwiseOrOpTok);
23022624 if (p.depths[def_index] > max_depth) return error.MaxDepth;
23032625 p.depths[def_index] += 1;
23042626 defer p.depths[def_index] -= 1;
23052627 return blk_0: {
23062628 const pos_0 = p.i;
2307 if (try p.parseAMPERSAND() and blk_1: {
2629 if (try p.parsePIPE()) break :blk_0 true;
2630 p.i = pos_0;
2631 break :blk_0 false;
2632 };
2633 }
2634 pub fn parseBitwiseXorOp(p: *Parser) Error!bool {
2635 const def_index = @backingInt(Def.defBitwiseXorOp);
2636 if (p.depths[def_index] > max_depth) return error.MaxDepth;
2637 p.depths[def_index] += 1;
2638 defer p.depths[def_index] -= 1;
2639 return blk_0: {
2640 const pos_0 = p.i;
2641 if (try p.parsepre_op_white() and try p.parseBitwiseXorOpTok() and try p.parsepost_op_white()) break :blk_0 true;
2642 p.i = pos_0;
2643 if (blk_1: {
23082644 const pos_1 = p.i;
2309 const match_1 = (p.i < p.source.len and switch (p.source[p.i]) {
2310 '&'...'&',
2311 => blk_2: {
2312 p.i += 1;
2313 break :blk_2 true;
2314 },
2315 else => false,
2316 });
2645 const match_1 = try p.parsepre_op_white();
2646 p.i = pos_1;
2647 break :blk_1 !match_1;
2648 } and try p.parseBitwiseXorOpTok() and blk_1: {
2649 const pos_1 = p.i;
2650 const match_1 = try p.parsepost_op_white();
23172651 p.i = pos_1;
23182652 break :blk_1 !match_1;
23192653 }) break :blk_0 true;
23202654 p.i = pos_0;
2655 break :blk_0 false;
2656 };
2657 }
2658 pub fn parseBitwiseXorOpTok(p: *Parser) Error!bool {
2659 const def_index = @backingInt(Def.defBitwiseXorOpTok);
2660 if (p.depths[def_index] > max_depth) return error.MaxDepth;
2661 p.depths[def_index] += 1;
2662 defer p.depths[def_index] -= 1;
2663 return blk_0: {
2664 const pos_0 = p.i;
23212665 if (try p.parseCARET()) break :blk_0 true;
23222666 p.i = pos_0;
2323 if (try p.parsePIPE()) break :blk_0 true;
2667 break :blk_0 false;
2668 };
2669 }
2670 pub fn parseCatchOp(p: *Parser) Error!bool {
2671 const def_index = @backingInt(Def.defCatchOp);
2672 if (p.depths[def_index] > max_depth) return error.MaxDepth;
2673 p.depths[def_index] += 1;
2674 defer p.depths[def_index] -= 1;
2675 return blk_0: {
2676 const pos_0 = p.i;
2677 if (try p.parsepre_op_white() and try p.parseKEYWORD_catch() and try p.parsepost_op_white() and (try p.parsePayload() or true)) break :blk_0 true;
23242678 p.i = pos_0;
2325 if (try p.parseKEYWORD_orelse()) break :blk_0 true;
2679 if (blk_1: {
2680 const pos_1 = p.i;
2681 const match_1 = try p.parsepre_op_white();
2682 p.i = pos_1;
2683 break :blk_1 !match_1;
2684 } and try p.parseKEYWORD_catch() and blk_1: {
2685 const pos_1 = p.i;
2686 const match_1 = try p.parsepost_op_white();
2687 p.i = pos_1;
2688 break :blk_1 !match_1;
2689 } and (try p.parsePayload() or true)) break :blk_0 true;
2690 p.i = pos_0;
2691 break :blk_0 false;
2692 };
2693 }
2694 pub fn parseOrElseOp(p: *Parser) Error!bool {
2695 const def_index = @backingInt(Def.defOrElseOp);
2696 if (p.depths[def_index] > max_depth) return error.MaxDepth;
2697 p.depths[def_index] += 1;
2698 defer p.depths[def_index] -= 1;
2699 return blk_0: {
2700 const pos_0 = p.i;
2701 if (try p.parsepre_op_white() and try p.parseKEYWORD_orelse() and try p.parsepost_op_white()) break :blk_0 true;
2702 p.i = pos_0;
2703 if (blk_1: {
2704 const pos_1 = p.i;
2705 const match_1 = try p.parsepre_op_white();
2706 p.i = pos_1;
2707 break :blk_1 !match_1;
2708 } and try p.parseKEYWORD_orelse() and blk_1: {
2709 const pos_1 = p.i;
2710 const match_1 = try p.parsepost_op_white();
2711 p.i = pos_1;
2712 break :blk_1 !match_1;
2713 }) break :blk_0 true;
23262714 p.i = pos_0;
23272715 break :blk_0 false;
23282716 };
......@@ -2452,8 +2840,6 @@ const Parser = struct {
24522840 p.i = pos_0;
24532841 if (try p.parseSLASH()) break :blk_0 true;
24542842 p.i = pos_0;
2455 if (try p.parsePERCENT()) break :blk_0 true;
2456 p.i = pos_0;
24572843 if (try p.parseASTERISKPERCENT()) break :blk_0 true;
24582844 p.i = pos_0;
24592845 if (try p.parseASTERISKPIPE()) break :blk_0 true;
......@@ -2461,6 +2847,30 @@ const Parser = struct {
24612847 break :blk_0 false;
24622848 };
24632849 }
2850 pub fn parseModOp(p: *Parser) Error!bool {
2851 const def_index = @backingInt(Def.defModOp);
2852 if (p.depths[def_index] > max_depth) return error.MaxDepth;
2853 p.depths[def_index] += 1;
2854 defer p.depths[def_index] -= 1;
2855 return blk_0: {
2856 const pos_0 = p.i;
2857 if (try p.parsepre_op_white() and try p.parsePERCENT() and try p.parsepost_op_white()) break :blk_0 true;
2858 p.i = pos_0;
2859 if (blk_1: {
2860 const pos_1 = p.i;
2861 const match_1 = try p.parsepre_op_white();
2862 p.i = pos_1;
2863 break :blk_1 !match_1;
2864 } and try p.parsePERCENT() and blk_1: {
2865 const pos_1 = p.i;
2866 const match_1 = try p.parsepost_op_white();
2867 p.i = pos_1;
2868 break :blk_1 !match_1;
2869 }) break :blk_0 true;
2870 p.i = pos_0;
2871 break :blk_0 false;
2872 };
2873 }
24642874 pub fn parsePrefixOp(p: *Parser) Error!bool {
24652875 const def_index = @backingInt(Def.defPrefixOp);
24662876 if (p.depths[def_index] > max_depth) return error.MaxDepth;