Expand description
A parser for selection expressions in a compact textual syntax.
See [selection::parse] for syntax details and examples.
This module defines a parser of a compact syntax used to
describe hierarchical selections over multidimensional meshes.
expression ::= union
union ::= intersection ( "|" intersection )*
intersection ::= chain ( "&" chain )*
chain ::= group ( "," group )*
group ::= range
| index
| wildcard
| any
| "(" expression ")"
range ::= number? ":" number? ( ":" number )?
index ::= number
wildcard ::= "*"
any ::= "?"
number ::= [0-9]+Notes:
,separates nested dimensions (i.e., descent into next dimension).|is union,&is intersection.&binds tighter than|.*selects all values at the current dimension and descends.?selects a random value at the current dimension and descends.- A range like
2:5:1has the formstart:end:step. Missing parts default to:start = 0end = full extentstep = 1
- An index like
3is shorthand for the range3:4. - Parentheses
()allow grouping for precedence control and nesting of chains. - Whitespace is not allowed (although the
parsefunction will admit and strip it.) - Expressions like
(*,*,1:4|5:6)are valid and parsed as:- A union of two expressions:
- The chain
*,*,1:4 - The standalone
5:6
- The chain
- The union applies at the top level, not just within a dimension.
- To apply the union only to the third dimension, parentheses must be used:
e.g.,
*,*,(1:4|5:6)
- A union of two expressions:
Functionsยง
- expression
- parse
- Parses a selection expression from a string, ignoring all whitespace.