surroundedBy method
Expects to see the pattern, surrounded by the others.
If no right
is provided, it expects to see the same pattern on both sides.
Use this parse things like parenthesized expressions, arrays, etc.
Implementation
Parser<T> surroundedBy(Parser left, [Parser? right]) {
return chain([
left,
this,
right ?? left,
]).index(1).castDynamic().cast<T>();
}