Skip to content
kareman edited this page Aug 23, 2020 · 5 revisions

Skip

Skips 0 or more elements until a match for the next patterns is found.

public struct Skip<Input: BidirectionalCollection>: Pattern where Input.Element: Hashable
let s = Skip()  a

is 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.

Inheritance

Pattern, RegexConvertible

Initializers

init()

@inlinable public init()

init()

@inlinable public init() where Input == String

Properties

description

var description: String

regex

var regex: String

Methods

createInstructions(_:)

@inlinable public func createInstructions(_ instructions: inout ContiguousArray<Instruction<Input>>) throws
Clone this wiki locally