Skip to content

Commit ff82da9

Browse files
hyperpolymathclaude
andcommitted
feat(parser): extend Rust parser
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 3b39fb5 commit ff82da9

2 files changed

Lines changed: 121 additions & 121 deletions

File tree

src/rust/src/parser.rs

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ mod tests {
881881
assert!(params.is_empty());
882882
assert_eq!(*body.kind, ExprKind::Identity);
883883
}
884-
_ => panic!("expected Def"),
884+
other => panic!("expected Def, got {other:?}"),
885885
}
886886
}
887887

@@ -893,7 +893,7 @@ mod tests {
893893
assert_eq!(name, "f");
894894
assert_eq!(params, &["x", "y"]);
895895
}
896-
_ => panic!("expected Def"),
896+
other => panic!("expected Def, got {other:?}"),
897897
}
898898
}
899899

@@ -907,9 +907,9 @@ mod tests {
907907
assert_eq!(gens[0].index, 1);
908908
assert!(!gens[0].inverse);
909909
}
910-
_ => panic!("expected BraidLit"),
910+
other => panic!("expected BraidLit, got {other:?}"),
911911
},
912-
_ => panic!("expected Def"),
912+
other => panic!("expected Def, got {other:?}"),
913913
}
914914
}
915915

@@ -923,9 +923,9 @@ mod tests {
923923
assert_eq!(gens[0].index, 2);
924924
assert!(gens[0].inverse);
925925
}
926-
_ => panic!("expected BraidLit"),
926+
other => panic!("expected BraidLit, got {other:?}"),
927927
},
928-
_ => panic!("expected Def"),
928+
other => panic!("expected Def, got {other:?}"),
929929
}
930930
}
931931

@@ -935,9 +935,9 @@ mod tests {
935935
match &prog.stmts[0].kind {
936936
StmtKind::Def { body, .. } => match body.kind.as_ref() {
937937
ExprKind::BraidLit(gens) => assert!(gens.is_empty()),
938-
_ => panic!("expected BraidLit"),
938+
other => panic!("expected BraidLit, got {other:?}"),
939939
},
940-
_ => panic!("expected Def"),
940+
other => panic!("expected Def, got {other:?}"),
941941
}
942942
}
943943

@@ -950,7 +950,7 @@ mod tests {
950950
StmtKind::Assert { expr } => {
951951
assert!(matches!(expr.kind.as_ref(), ExprKind::Eq(..)));
952952
}
953-
_ => panic!("expected Assert"),
953+
other => panic!("expected Assert, got {other:?}"),
954954
}
955955
}
956956

@@ -961,7 +961,7 @@ mod tests {
961961
StmtKind::Assert { expr } => {
962962
assert!(matches!(expr.kind.as_ref(), ExprKind::Isotopy(..)));
963963
}
964-
_ => panic!("expected Assert"),
964+
other => panic!("expected Assert, got {other:?}"),
965965
}
966966
}
967967

@@ -975,7 +975,7 @@ mod tests {
975975
assert_eq!(invariant, "jones");
976976
assert!(matches!(expr.kind.as_ref(), ExprKind::Close(..)));
977977
}
978-
_ => panic!("expected Compute"),
978+
other => panic!("expected Compute, got {other:?}"),
979979
}
980980
}
981981

@@ -997,7 +997,7 @@ mod tests {
997997
assert_eq!(output_strands[0].name, "b");
998998
assert_eq!(output_strands[1].name, "a");
999999
}
1000-
_ => panic!("expected Weave"),
1000+
other => panic!("expected Weave, got {other:?}"),
10011001
}
10021002
}
10031003

@@ -1009,7 +1009,7 @@ mod tests {
10091009
assert_eq!(input_strands[0].type_ann.as_deref(), Some("Q"));
10101010
assert_eq!(input_strands[1].type_ann.as_deref(), Some("R"));
10111011
}
1012-
_ => panic!("expected Weave"),
1012+
other => panic!("expected Weave, got {other:?}"),
10131013
}
10141014
}
10151015

@@ -1023,7 +1023,7 @@ mod tests {
10231023
StmtKind::Def { body, .. } => {
10241024
assert!(matches!(body.kind.as_ref(), ExprKind::Add(..)));
10251025
}
1026-
_ => panic!("expected Def"),
1026+
other => panic!("expected Def, got {other:?}"),
10271027
}
10281028
}
10291029

@@ -1036,9 +1036,9 @@ mod tests {
10361036
ExprKind::Eq(lhs, _) => {
10371037
assert!(matches!(lhs.kind.as_ref(), ExprKind::Add(..)));
10381038
}
1039-
_ => panic!("expected Eq"),
1039+
other => panic!("expected Eq, got {other:?}"),
10401040
},
1041-
_ => panic!("expected Assert"),
1041+
other => panic!("expected Assert, got {other:?}"),
10421042
}
10431043
}
10441044

@@ -1051,9 +1051,9 @@ mod tests {
10511051
ExprKind::Add(_, rhs) => {
10521052
assert!(matches!(rhs.kind.as_ref(), ExprKind::Mul(..)));
10531053
}
1054-
_ => panic!("expected Add"),
1054+
other => panic!("expected Add, got {other:?}"),
10551055
},
1056-
_ => panic!("expected Def"),
1056+
other => panic!("expected Def, got {other:?}"),
10571057
}
10581058
}
10591059

@@ -1075,9 +1075,9 @@ mod tests {
10751075
ExprKind::Compose(_, rhs) => {
10761076
assert!(matches!(rhs.kind.as_ref(), ExprKind::Tensor(..)));
10771077
}
1078-
_ => panic!("expected Compose at top level"),
1078+
other => panic!("expected Compose at top level, got {other:?}"),
10791079
},
1080-
_ => panic!("expected Def"),
1080+
other => panic!("expected Def, got {other:?}"),
10811081
}
10821082
}
10831083

@@ -1089,9 +1089,9 @@ mod tests {
10891089
ExprKind::Pipeline(lhs, _) => {
10901090
assert!(matches!(lhs.kind.as_ref(), ExprKind::Pipeline(..)));
10911091
}
1092-
_ => panic!("expected Pipeline"),
1092+
other => panic!("expected Pipeline, got {other:?}"),
10931093
},
1094-
_ => panic!("expected Def"),
1094+
other => panic!("expected Def, got {other:?}"),
10951095
}
10961096
}
10971097

@@ -1112,9 +1112,9 @@ mod tests {
11121112
assert!(matches!(arms[0].pattern.kind, PatternKind::Identity));
11131113
assert!(matches!(arms[1].pattern.kind, PatternKind::Cons { .. }));
11141114
}
1115-
_ => panic!("expected Match"),
1115+
other => panic!("expected Match, got {other:?}"),
11161116
},
1117-
_ => panic!("expected Def"),
1117+
other => panic!("expected Def, got {other:?}"),
11181118
}
11191119
}
11201120

@@ -1126,9 +1126,9 @@ mod tests {
11261126
ExprKind::Match { arms, .. } => {
11271127
assert!(matches!(arms[0].pattern.kind, PatternKind::Wildcard));
11281128
}
1129-
_ => panic!("expected Match"),
1129+
other => panic!("expected Match, got {other:?}"),
11301130
},
1131-
_ => panic!("expected Def"),
1131+
other => panic!("expected Def, got {other:?}"),
11321132
}
11331133
}
11341134

@@ -1140,9 +1140,9 @@ mod tests {
11401140
ExprKind::Match { arms, .. } => {
11411141
assert!(matches!(&arms[0].pattern.kind, PatternKind::Var(n) if n == "y"));
11421142
}
1143-
_ => panic!("expected Match"),
1143+
other => panic!("expected Match, got {other:?}"),
11441144
},
1145-
_ => panic!("expected Def"),
1145+
other => panic!("expected Def, got {other:?}"),
11461146
}
11471147
}
11481148

@@ -1156,11 +1156,11 @@ mod tests {
11561156
assert_eq!(generator.index, 2);
11571157
assert!(generator.inverse);
11581158
}
1159-
_ => panic!("expected Cons pattern"),
1159+
other => panic!("expected Cons pattern, got {other:?}"),
11601160
},
1161-
_ => panic!("expected Match"),
1161+
other => panic!("expected Match, got {other:?}"),
11621162
},
1163-
_ => panic!("expected Def"),
1163+
other => panic!("expected Def, got {other:?}"),
11641164
}
11651165
}
11661166

@@ -1174,9 +1174,9 @@ mod tests {
11741174
ExprKind::Let { name, .. } => {
11751175
assert_eq!(name, "y");
11761176
}
1177-
_ => panic!("expected Let"),
1177+
other => panic!("expected Let, got {other:?}"),
11781178
},
1179-
_ => panic!("expected Def"),
1179+
other => panic!("expected Def, got {other:?}"),
11801180
}
11811181
}
11821182

@@ -1191,9 +1191,9 @@ mod tests {
11911191
assert_eq!(a, "a");
11921192
assert_eq!(b, "b");
11931193
}
1194-
_ => panic!("expected CrossOver"),
1194+
other => panic!("expected CrossOver, got {other:?}"),
11951195
},
1196-
_ => panic!("expected Def"),
1196+
other => panic!("expected Def, got {other:?}"),
11971197
}
11981198
}
11991199

@@ -1204,7 +1204,7 @@ mod tests {
12041204
StmtKind::Def { body, .. } => {
12051205
assert!(matches!(body.kind.as_ref(), ExprKind::CrossUnder { .. }));
12061206
}
1207-
_ => panic!("expected Def"),
1207+
other => panic!("expected Def, got {other:?}"),
12081208
}
12091209
}
12101210

@@ -1216,9 +1216,9 @@ mod tests {
12161216
ExprKind::Twist(inner) => {
12171217
assert!(matches!(inner.kind.as_ref(), ExprKind::Var(n) if n == "a"));
12181218
}
1219-
_ => panic!("expected Twist"),
1219+
other => panic!("expected Twist, got {other:?}"),
12201220
},
1221-
_ => panic!("expected Def"),
1221+
other => panic!("expected Def, got {other:?}"),
12221222
}
12231223
}
12241224

@@ -1230,9 +1230,9 @@ mod tests {
12301230
ExprKind::Twist(inner) => {
12311231
assert!(matches!(inner.kind.as_ref(), ExprKind::BraidLit(_)));
12321232
}
1233-
_ => panic!("expected Twist"),
1233+
other => panic!("expected Twist, got {other:?}"),
12341234
},
1235-
_ => panic!("expected Def"),
1235+
other => panic!("expected Def, got {other:?}"),
12361236
}
12371237
}
12381238

@@ -1247,9 +1247,9 @@ mod tests {
12471247
assert!(matches!(lhs.kind.as_ref(), ExprKind::Simplify(..)));
12481248
assert!(matches!(rhs.kind.as_ref(), ExprKind::Identity));
12491249
}
1250-
_ => panic!("expected Eq"),
1250+
other => panic!("expected Eq, got {other:?}"),
12511251
},
1252-
_ => panic!("expected Assert"),
1252+
other => panic!("expected Assert, got {other:?}"),
12531253
}
12541254
}
12551255

@@ -1260,7 +1260,7 @@ mod tests {
12601260
StmtKind::Compute { expr, .. } => {
12611261
assert!(matches!(expr.kind.as_ref(), ExprKind::Close(..)));
12621262
}
1263-
_ => panic!("expected Compute"),
1263+
other => panic!("expected Compute, got {other:?}"),
12641264
}
12651265
}
12661266

@@ -1271,15 +1271,15 @@ mod tests {
12711271
StmtKind::Def { body, .. } => {
12721272
assert!(matches!(body.kind.as_ref(), ExprKind::Mirror(..)));
12731273
}
1274-
_ => panic!("expected Def"),
1274+
other => panic!("expected Def, got {other:?}"),
12751275
}
12761276

12771277
let prog = parse_ok("def y = reverse(braid[s1])");
12781278
match &prog.stmts[0].kind {
12791279
StmtKind::Def { body, .. } => {
12801280
assert!(matches!(body.kind.as_ref(), ExprKind::Reverse(..)));
12811281
}
1282-
_ => panic!("expected Def"),
1282+
other => panic!("expected Def, got {other:?}"),
12831283
}
12841284
}
12851285

@@ -1290,15 +1290,15 @@ mod tests {
12901290
StmtKind::Def { body, .. } => {
12911291
assert!(matches!(body.kind.as_ref(), ExprKind::Cap(..)));
12921292
}
1293-
_ => panic!("expected Def"),
1293+
other => panic!("expected Def, got {other:?}"),
12941294
}
12951295

12961296
let prog = parse_ok("def y = cup(a, b)");
12971297
match &prog.stmts[0].kind {
12981298
StmtKind::Def { body, .. } => {
12991299
assert!(matches!(body.kind.as_ref(), ExprKind::Cup(..)));
13001300
}
1301-
_ => panic!("expected Def"),
1301+
other => panic!("expected Def, got {other:?}"),
13021302
}
13031303
}
13041304

@@ -1313,9 +1313,9 @@ mod tests {
13131313
assert_eq!(func, "f");
13141314
assert_eq!(args.len(), 2);
13151315
}
1316-
_ => panic!("expected App"),
1316+
other => panic!("expected App, got {other:?}"),
13171317
},
1318-
_ => panic!("expected Def"),
1318+
other => panic!("expected Def, got {other:?}"),
13191319
}
13201320
}
13211321

@@ -1327,9 +1327,9 @@ mod tests {
13271327
ExprKind::Add(_, rhs) => {
13281328
assert!(matches!(rhs.kind.as_ref(), ExprKind::App { .. }));
13291329
}
1330-
_ => panic!("expected Add"),
1330+
other => panic!("expected Add, got {other:?}"),
13311331
},
1332-
_ => panic!("expected Def"),
1332+
other => panic!("expected Def, got {other:?}"),
13331333
}
13341334
}
13351335

@@ -1358,9 +1358,9 @@ mod tests {
13581358
ExprKind::Mul(lhs, _) => {
13591359
assert!(matches!(lhs.kind.as_ref(), ExprKind::Add(..)));
13601360
}
1361-
_ => panic!("expected Mul"),
1361+
other => panic!("expected Mul, got {other:?}"),
13621362
},
1363-
_ => panic!("expected Def"),
1363+
other => panic!("expected Def, got {other:?}"),
13641364
}
13651365
}
13661366

0 commit comments

Comments
 (0)