-
Notifications
You must be signed in to change notification settings - Fork 1
Skip
kareman edited this page Aug 23, 2020
·
5 revisions
Skips 0 or more elements until a match for the next patterns is found.
public struct Skip<Input: BidirectionalCollection>: Pattern where Input.Element: Hashablelet s = Skip() • ais the same as |S <- A / . <S>| in standard PEG.
Note: If `Skip` is at the end of a pattern, it just succeeds without consuming input. So it will be pointless.
But this works:
let s = Skip()
let p = s • " "because here the s pattern is "inlined".
This, however, does not work:
let g = Grammar { g in
g.nextSpace <- g.skip • " "
g.skip <- Skip()
}because in grammars the subexpressions are called, like functions, not "inlined", like Swift variables.
So the Skip() in g.skip can't tell what will come after it.
@inlinable public init()@inlinable public init() where Input == Stringvar description: Stringvar regex: String@inlinable public func createInstructions(_ instructions: inout ContiguousArray<Instruction<Input>>) throwsGenerated at 2020-08-23T12:56:49+0000 using swift-doc 1.0.0-beta.3.