Skip to content
FutureBlitz

    Install

    Import std.text.scanner

    std.text.scanner

    Scanner: reads text from its start, a character, a word, a line, or a number at a time, for a parser, and keeps the Line and Column of what it reads next, where an error can point. A line ends at "\n", and a column counts characters, code points, from 1.

    std/text/scanner.fb

    Types

    Scanner class

    Public Class Scanner

    Reads text from its start, a character, a word, a line, or a number at a time, keeping the Line and Column of what it reads next.

    std/text/scanner.fb, line 17

    • Public ReadOnly Field Text: String field #

      The text it reads.

    • Public New(text: String) constructor #

      One that reads text from its start.

    • Public Property Position: Int property #

      The position of the next character it reads, a byte offset in Text.

    • Public Property Line: Int property #

      The line of the next character it reads, from 1.

    • Public Property Column: Int property #

      The column of the next character it reads, from 1, counting characters.

    • Public Method AtEnd(): Bool method #

      Whether it has read all of Text.

    • Public Method Peek(): Char? method #

      The next character, without reading it, or Null at the end.

    • Public Method Next(): Char? method #

      Reads the next character, and gives it, or Null at the end.

    • Public Method Take(text: String): Bool method #

      Reads text when it comes next, and gives whether it did.

    • Public Method TakeWhile(keep: Func(Char): Bool): String method #

      Reads the characters keep says to, up to the first it doesn't, and gives them.

    • Public Method SkipWhitespace() method #

      Reads the whitespace that comes next, up to the first other character.

    • Public Method TakeUntil(text: String): String method #

      Reads up to text, or to the end when text doesn't come, and gives what it read, without text, which comes next.

    • Public Method TakeLine(): String? method #

      Reads the rest of the line and its line break, "\n" or "\r\n", and gives the line without it, or Null at the end. The last line, with no "\n" after it, is all of what's left.

    • Public Method TakeWord(): String? method #

      Reads the whitespace that comes next and the word after it, the characters up to the next whitespace, and gives the word, or Null when only whitespace is left.

    • Public Method TakeInt(): Int64? method #

      Reads an integer that comes next: a "-" or "+", or neither, then the digits 0 to 9, and gives it, or Null, reading nothing, when no digit comes or it doesn't fit in an Int64.

    • Public Method TakeRest(): String method #

      Reads the rest of Text, and gives it.

    Report an issue with this page or with FutureBlitz on GitHub.