• Effekt Logo Effekt Library
    • scanner
      • Scan
        • peek
        • skip
      • read
      • scanner
      • expect
      • readWhen
      • readIf
      • skipIf
      • mustSkip
      • mustSkip
      • readMany
      • readSome
      • skipMany
      • skipSome
      • readIf
      • skipIf
      • until
      • line
      • list
      • list
      • skipWhitespace
      • readString
      • readDigit
      • readDecimal
      • readHexDigit
      • readHexadecimal
      • readInteger
      • returning
        • scanner
        • expect
      • test
        • main
    • scanner
    • Jump to source: libraries/common/scanner.effekt
      Example usage: examples/stdlib/scanner
      • Scan [A]
        • peek : A / {stop}
        • Return the next character, not advancing.
          That is, this does not change what any future calls on the Scanner return.
        • skip : Unit / {stop}
        • Advance the Scanner to the next character.
      • read [A]: A / {Scan[A], stop}
      • Advance the Scanner to the next token, returning it.
      • scanner [A] { scanner: => Unit / {Scan[A]} }: Unit / {read[A]}
      • Run a scanner by reading from an input stream, discarding its output.
      • expect (message: String) { scanner: => Unit / {fail} }: Unit / {Exception[WrongFormat]}
      • readWhen [A, B] { convert: (A) => B / {fail} }: B / {Scan[A], stop}
      • If conversion is successful read the next token, otherwise stop.
      • readIf [A] { predicate: (A) => Bool }: A / {Scan[A], stop}
      • Check that the next token satisfies the predicate and skip and return it when it does.
      • skipIf [A] { predicate: (A) => Bool }: Unit / {Scan[A], stop}
      • Check that the next token satisfies the predicate and skip it when it does.
      • mustSkip [A]: Unit / {Scan[A], fail}
      • Skips the next token but fails instead of stopping.
      • mustSkip (token: Char): Unit / {Scan[Char], fail}
      • Skips the next character but fails if it is not the given one.
      • readMany [A] { predicate: (A) => Bool }: Unit / {Scan[A], emit[A]}
      • Reads until the predicate does not hold for the next token.
        Emits the tokens read.
      • readSome [A] { predicate: (A) => Bool }: Unit / {Scan[A], emit[A], fail}
      • Reads until the predicate does not hold for the next token.
        Must read at least one token, else fails.
        Emits the tokens read.
      • skipMany [A] { predicate: (A) => Bool }: Unit / {Scan[A]}
      • Skips until the predicate does not hold for the next token.
      • skipSome [A] { predicate: (A) => Bool }: Unit / {Scan[A], fail}
      • Skips until the predicate does not hold for the next token.
        Must skip at least one token, else fail.
      • readIf (e: Char): Unit / {Scan[Char], stop}
      • Read the next character if it is the given one.
      • skipIf (e: Char): Unit / {Scan[Char], stop}
      • Check that the next token satisfies the predicate and skip it when it does.
      • until [A, R] { predicate: (A) => Bool } { scanner: => R / {Scan[A]} }: R / {Scan[A], stop}
      • Read tokens and supply them to the given scanner.
        Stop and skip whenn the predicate is true.
        Immediately stops when already at the end.
      • line [R] { scanner: => R / {Scan[Char]} }: R / {Scan[Char], stop}
      • Read the next line and supply each character to the given scanner.
      • list [A] { seperator: => Unit / {stop} } { action: => A / {stop} }: Unit / {emit[A]}
      • Read values produced by `action` followed by `separator` until one of them stops.
        Will consume a trailing separator.
      • list [A] (seperator: Char) { action: => A / {stop} }: Unit / {Scan[Char], emit[A]}
      • Read a sequence separated by `separator`.
        Will consume a trailing separator.
      • skipWhitespace : Unit / {Scan[Char]}
      • Skip until the next character is not a whitespace character.
      • readString (string: String): Unit / {Scan[Char], fail}
      • Read a prefix of the characters of the given string.
        Fails when it cannot read all of them.
      • readDigit : Int / {Scan[Char], stop}
      • Check that the next character is a digit in base 10, and if so read and return it.
      • readDecimal : Int / {Scan[Char], fail}
      • Read a positive decimal number.
        Fails when there isn't at least one digit.
      • readHexDigit : Int / {Scan[Char], stop}
      • Check that the next character is a digit in base 16, and if so read and return it.
      • readHexadecimal : Int / {Scan[Char], fail}
      • Read a hexadecimal number.
        Fails when there isn't at least one digit.
      • readInteger : Int / {Scan[Char], fail}
      • Read a decimal integer.
        Will consume a minus sign if it is not followed by a digit.
        Fails whenn there isn't at least one digit.
      • returning
        • scanner [A, R] { scanner: => R / {Scan[A]} }: R / {read[A]}
        • Run a scanner by reading from an input stream.
        • expect [R] (message: String) { scanner: => R / {fail} }: R / {Exception[WrongFormat]}
      • test
        • main : Unit / {}