I'm parsing a stream with record fragments that are always sequential, but not always consecutive, e.g., in the example below line 1 and 3 are part of the same record and while line 1 will always come before line 3 it is possible to get an entirely unrelated line between them, in this case line 2, which parenthetically needs to be matched up with line 4.
1: [[aaaa
2: [[bbbb
3: aaaa]]
4: bbbb]]
If there is deterministic way to match the record fragments, could ANTLR handle this kind of fragmentation? If so, what would the grammar look like?