Skip to content
kareman edited this page Aug 13, 2020 · 9 revisions

Types

  • Line:​ Matches one line, not including newline characters.
  • Line.Start:​ Matches the start of a line, including the start of input.
  • Line.End:​ Matches the end of a line, including the end of input.
  • Literal:​ Matches a sequence of elements.
  • OneOf:​ Matches and consumes a single element.
  • Word
  • Word.Boundary:​ Detects boundaries between words.
  • Parser.Match.MatchDecoder
  • Grammar:​ Allows for recursive patterns, also indirectly.
  • Grammar.CallPattern:​ Calls another subpattern in a grammar.
  • AndPattern:​ A pattern which matches the wrapped pattern, without consuming any input.
  • AnyPattern:​ A type erased wrapper around a pattern. Can be used to store patterns in arrays and non-generic variables.
  • AnyPattern.StringInterpolation
  • Capture:​ Captures the current position as a range.
  • NoPattern:​ A pattern that does absolutely nothing.
  • OrPattern:​ A pattern which first tries the first pattern, if that fails it tries the second pattern from the same position.
  • Concat:​ A pattern which first tries the first pattern, if that succeeds it continues with the second pattern.
  • NotPattern:​ A pattern which only succeeds if the wrapped pattern fails. The next pattern will continue from where wrapped started.
  • RepeatPattern:​ Repeats the wrapped pattern min times, then repeats it optionally max-min times. Or an unlimited number of times if max is nil.
  • Skip:​ Skips 0 or more elements until a match for the next patterns are found.
  • Parser:​ Takes a pattern, optimises it and tries to match it over an input.
  • Parser.PatternError:​ Indicates a problem with a malformed pattern.
  • Parser.Match:​ Contains information about a patterns successfully completed match.
  • Instruction:​ The instructions used by patterns in createInstructions.

Protocols

Operators

  • •(lhs:​rhs:​)
  • •(lhs:​rhs:​)
  • •(lhs:​rhs:​)
  • •(lhs:​rhs:​)
  • /(lhs:​rhs:​)
  • /(lhs:​rhs:​)
  • <-(call:​pattern:​):​ Used by grammars to define subpatterns with g.a <- ....
  • <-(call:​capture:​):​ In case of g.name <- Capture(...), names the nameless Capture "name".
  • /(p1:​p2:​):​ First tries the pattern to the left, if that fails it tries the pattern to the right from the same position.
  • /(p1:​p2:​):​ First tries the pattern to the left, if that fails it tries the pattern to the right from the same position.
  • /(p1:​p2:​):​ First tries the pattern to the left, if that fails it tries the pattern to the right from the same position.
  • /(p1:​p2:​):​ First tries the pattern to the left, if that fails it tries the pattern to the right from the same position.
  • /(p1:​p2:​):​ First tries the pattern to the left, if that fails it tries the pattern to the right from the same position.
  • •(lhs:​rhs:​):​ First tries the pattern to the left, if that succeeds it tries the pattern to the right.
  • •(lhs:​rhs:​):​ First tries the pattern to the left, if that succeeds it tries the pattern to the right.
  • •(lhs:​rhs:​):​ First tries the pattern to the left, if that succeeds it tries the pattern to the right.
  • •(lhs:​rhs:​):​ First tries the pattern to the left, if that succeeds it tries the pattern to the right.
  • !(pattern:​):​ Will only succeed if the following pattern fails. Does not consume any input.
  • !(pattern:​):​ Will only succeed if the following pattern fails. Does not consume any input.
  • *(me:​):​ Repeats the preceding pattern 0 or more times.
  • *(me:​):​ Repeats the preceding pattern 0 or more times.
  • +(me:​):​ Repeats the preceding pattern 1 or more times.
  • +(me:​):​ Repeats the preceding pattern 1 or more times.
  • ¿(me:​):​ Tries the preceding pattern, and continues even if it fails.
  • ¿(me:​):​ Tries the preceding pattern, and continues even if it fails.

Global Functions

Global Variables

  • any:​ Succeeds anywhere except for at the end of input, and consumes 1 element.
  • letter:​ Matches one character representing a letter, i.e. where Character.isLetter is true.
  • lowercase:​ Matches one character representing a lowercase character, i.e. where Character.isLowercase is true.
  • uppercase:​ Matches one character representing an uppercase character, i.e. where Character.isUppercase is true.
  • digit:​ Matches one character representing a whole number, i.e. where Character.isWholeNumber is true.
  • alphanumeric:​ Matches one letter or one digit.
  • newline:​ Matches one character representing a newline, i.e. where Character.isNewline is true.
  • whitespace:​ Matches one character representing whitespace (including newlines), i.e. where Character.isWhitespace is true.
  • punctuation:​ Matches one character representing punctuation, i.e. where Character.isPunctuation is true.
  • symbol:​ Matches one character representing a symbol, i.e. where Character.isSymbol is true.
  • hexDigit:​ Matches one character representing a hexadecimal digit, i.e. where Character.isHexDigit is true.
  • ascii:​ Matches one ASCII character, i.e. where Character.isASCII is true.
  • mathSymbol:​ Matches one character representing a mathematical symbol, i.e. where Character.isMathSymbol is true.
  • currencySymbol:​ Matches one character representing a currency symbol, i.e. where Character.isCurrencySymbol is true.
Clone this wiki locally