Skip to content

Commit bf5bf5f

Browse files
authored
generate: support nested records. (#138)
generate: support nested records.
2 parents cbed0ec + 54ad119 commit bf5bf5f

File tree

3 files changed

+247
-65
lines changed

3 files changed

+247
-65
lines changed

macros/tests/basic.rs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ testcases![
199199
Bar:{ "a" field:"b"? } |
200200
Baz:{ baz:"ab" };
201201
}:
202+
A("a") => "\
203+
1:1-1:2 => A::Bar",
202204
A("ab") => "\
203205
1:1-1:3 => A::Foo(
204206
1:1-1:3,
@@ -207,4 +209,46 @@ testcases![
207209
} | A::Baz {
208210
baz: 1:1-1:3,
209211
}";
212+
213+
nested_records {
214+
A = "a" nested:{ b:"b" c:"c"* d:"d"? } list:{ e:"e"? "f" }* "g";
215+
}:
216+
A("abg") => "\
217+
1:1-1:4 => A {
218+
nested: 1:2-1:3 => {
219+
b: 1:2-1:3,
220+
c: 1:3-1:3 => [],
221+
d: None,
222+
},
223+
list: 1:3-1:3 => [],
224+
}",
225+
A("abcccdeffefg") => "\
226+
1:1-1:13 => A {
227+
nested: 1:2-1:7 => {
228+
b: 1:2-1:3,
229+
c: 1:3-1:6 => [
230+
1:3-1:4,
231+
1:4-1:5,
232+
1:5-1:6,
233+
],
234+
d: Some(
235+
1:6-1:7,
236+
),
237+
},
238+
list: 1:7-1:12 => [
239+
1:7-1:9 => {
240+
e: Some(
241+
1:7-1:8,
242+
),
243+
},
244+
1:9-1:10 => {
245+
e: None,
246+
},
247+
1:10-1:12 => {
248+
e: Some(
249+
1:10-1:11,
250+
),
251+
},
252+
],
253+
}";
210254
];

0 commit comments

Comments
 (0)