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