Reputation: 1436
I want to learn auto layout and see this official document.In Visual Format String Grammar chapter,I don't understand Replacement rule.What does "?" and "*" means?
Upvotes: 1
Views: 311
Reputation: 108159
The definition of the grammar is given in a sort of EBNF form, which is used in computer science to describe context-free grammars.
Specifically,
?
expresses optionality, meaning 0 or 1 repetitions*
expresses 0 or more repetitions|
expresses an alternativeFor instance
(<predicate>(,<predicate>)*)
means a <predicate>
, followed by an arbitrary number of ,<predicate>
, possibly 0.
And
[<viewName>(<predicateListWithParens>)?]
means either [<viewName><predicateListWithParens>]
or just [<viewName>]
Finally
H|V
means either H
or V
.
Upvotes: 2