Namespace: go.std.text.scanner
v1.0Contents
Summary
Provides a low-level interface to the text/scanner package.
Package scanner provides a scanner and tokenizer for UTF-8-encoded text.
It takes an io.Reader providing the source, which then can be tokenized
through repeated calls to the Scan function. For compatibility with
existing tools, the NUL character is not allowed. If the first character
in the source is a UTF-8 encoded byte order mark (BOM), it is discarded.
By default, a Scanner skips white space and Go comments and recognizes all
literals as defined by the Go language specification. It may be
customized to recognize only a subset of those literals and to recognize
different identifier and white space characters.
Index
- *Position
- *Scanner
- Char
- Comment
- EOF
- Float
- GoTokens
- GoWhitespace
- Ident
- Int
- Position
- RawString
- ScanChars
- ScanComments
- ScanFloats
- ScanIdents
- ScanInts
- ScanRawStrings
- ScanStrings
- Scanner
- SkipComments
- String
- TokenString
- arrayOfPosition
- arrayOfScanner
Legend
- 
      Constant
      Variable
      Function
      Macro
      Special form
      Type
      GoVar
      Receiver/Method
    
Constants
Constants are variables with :const true in their metadata. Joker currently does not recognize them as special; as such, it allows redefining them or their values.- 
  CharInt v1.0The result of Scan is one of these tokens or a Unicode character. 
 
- 
  CommentInt v1.0The result of Scan is one of these tokens or a Unicode character. 
 
- 
  EOFInt v1.0The result of Scan is one of these tokens or a Unicode character. 
 
- 
  FloatInt v1.0The result of Scan is one of these tokens or a Unicode character. 
 
- 
  GoTokensInt v1.0Predefined mode bits to control recognition of tokens. For instance, 
 to configure a Scanner such that it only recognizes (Go) identifiers,
 integers, and skips comments, set the Scanner's Mode field to:
 
 ScanIdents | ScanInts | SkipComments
 
 With the exceptions of comments, which are skipped if SkipComments is
 set, unrecognized tokens are not ignored. Instead, the scanner simply
 returns the respective individual characters (or possibly sub-tokens).
 For instance, if the mode is ScanIdents (not ScanStrings), the string
 "foo" is scanned as the token sequence '"' Ident '"'.
 
 Use GoTokens to configure the Scanner such that it accepts all Go
 literal tokens including Go identifiers. Comments will be skipped.
 
- 
  GoWhitespaceInt v1.0GoWhitespace is the default value for the Scanner's Whitespace field. 
 Its value selects Go's white space characters.
 
- 
  IdentInt v1.0The result of Scan is one of these tokens or a Unicode character. 
 
- 
  IntInt v1.0The result of Scan is one of these tokens or a Unicode character. 
 
- 
  RawStringInt v1.0The result of Scan is one of these tokens or a Unicode character. 
 
- 
  ScanCharsInt v1.0Predefined mode bits to control recognition of tokens. For instance, 
 to configure a Scanner such that it only recognizes (Go) identifiers,
 integers, and skips comments, set the Scanner's Mode field to:
 
 ScanIdents | ScanInts | SkipComments
 
 With the exceptions of comments, which are skipped if SkipComments is
 set, unrecognized tokens are not ignored. Instead, the scanner simply
 returns the respective individual characters (or possibly sub-tokens).
 For instance, if the mode is ScanIdents (not ScanStrings), the string
 "foo" is scanned as the token sequence '"' Ident '"'.
 
 Use GoTokens to configure the Scanner such that it accepts all Go
 literal tokens including Go identifiers. Comments will be skipped.
 
- 
  ScanCommentsInt v1.0Predefined mode bits to control recognition of tokens. For instance, 
 to configure a Scanner such that it only recognizes (Go) identifiers,
 integers, and skips comments, set the Scanner's Mode field to:
 
 ScanIdents | ScanInts | SkipComments
 
 With the exceptions of comments, which are skipped if SkipComments is
 set, unrecognized tokens are not ignored. Instead, the scanner simply
 returns the respective individual characters (or possibly sub-tokens).
 For instance, if the mode is ScanIdents (not ScanStrings), the string
 "foo" is scanned as the token sequence '"' Ident '"'.
 
 Use GoTokens to configure the Scanner such that it accepts all Go
 literal tokens including Go identifiers. Comments will be skipped.
 
- 
  ScanFloatsInt v1.0includes Ints and hexadecimal floats 
 
- 
  ScanIdentsInt v1.0Predefined mode bits to control recognition of tokens. For instance, 
 to configure a Scanner such that it only recognizes (Go) identifiers,
 integers, and skips comments, set the Scanner's Mode field to:
 
 ScanIdents | ScanInts | SkipComments
 
 With the exceptions of comments, which are skipped if SkipComments is
 set, unrecognized tokens are not ignored. Instead, the scanner simply
 returns the respective individual characters (or possibly sub-tokens).
 For instance, if the mode is ScanIdents (not ScanStrings), the string
 "foo" is scanned as the token sequence '"' Ident '"'.
 
 Use GoTokens to configure the Scanner such that it accepts all Go
 literal tokens including Go identifiers. Comments will be skipped.
 
- 
  ScanIntsInt v1.0Predefined mode bits to control recognition of tokens. For instance, 
 to configure a Scanner such that it only recognizes (Go) identifiers,
 integers, and skips comments, set the Scanner's Mode field to:
 
 ScanIdents | ScanInts | SkipComments
 
 With the exceptions of comments, which are skipped if SkipComments is
 set, unrecognized tokens are not ignored. Instead, the scanner simply
 returns the respective individual characters (or possibly sub-tokens).
 For instance, if the mode is ScanIdents (not ScanStrings), the string
 "foo" is scanned as the token sequence '"' Ident '"'.
 
 Use GoTokens to configure the Scanner such that it accepts all Go
 literal tokens including Go identifiers. Comments will be skipped.
 
- 
  ScanRawStringsInt v1.0Predefined mode bits to control recognition of tokens. For instance, 
 to configure a Scanner such that it only recognizes (Go) identifiers,
 integers, and skips comments, set the Scanner's Mode field to:
 
 ScanIdents | ScanInts | SkipComments
 
 With the exceptions of comments, which are skipped if SkipComments is
 set, unrecognized tokens are not ignored. Instead, the scanner simply
 returns the respective individual characters (or possibly sub-tokens).
 For instance, if the mode is ScanIdents (not ScanStrings), the string
 "foo" is scanned as the token sequence '"' Ident '"'.
 
 Use GoTokens to configure the Scanner such that it accepts all Go
 literal tokens including Go identifiers. Comments will be skipped.
 
- 
  ScanStringsInt v1.0Predefined mode bits to control recognition of tokens. For instance, 
 to configure a Scanner such that it only recognizes (Go) identifiers,
 integers, and skips comments, set the Scanner's Mode field to:
 
 ScanIdents | ScanInts | SkipComments
 
 With the exceptions of comments, which are skipped if SkipComments is
 set, unrecognized tokens are not ignored. Instead, the scanner simply
 returns the respective individual characters (or possibly sub-tokens).
 For instance, if the mode is ScanIdents (not ScanStrings), the string
 "foo" is scanned as the token sequence '"' Ident '"'.
 
 Use GoTokens to configure the Scanner such that it accepts all Go
 literal tokens including Go identifiers. Comments will be skipped.
 
- 
  SkipCommentsInt v1.0if set with ScanComments, comments become white space 
 
- 
  StringInt v1.0The result of Scan is one of these tokens or a Unicode character. 
 
Variables
- 
      (None.)
    
Functions, Macros, and Special Forms
- 
  TokenStringFunction v1.0(TokenString tok)TokenString returns a printable string for a token or Unicode character. 
 
 Go input arguments: (tok rune)
 
 Go returns: string
 
 Joker input arguments: [^Char tok]
 
 Joker returns: ^String
Types
- 
  *PositionConcrete Type v1.0Position is a value that represents a source position. 
 A position is valid if Line > 0.
 
- 
    IsValidReceiver for *Position v1.0([])IsValid reports whether the position is valid. 
 
- 
  *ScannerConcrete Type v1.0A Scanner implements reading of Unicode characters and tokens from an io.Reader. 
 
- 
    InitReceiver for *Scanner v1.0([src])Init initializes a Scanner with a new source and returns s. 
 Error is set to nil, ErrorCount is set to 0, Mode is set to GoTokens,
 and Whitespace is set to GoWhitespace.
 
- 
    IsValidReceiver for *Scanner v1.0([])IsValid reports whether the position is valid. 
 
- 
    NextReceiver for *Scanner v1.0([])Next reads and returns the next Unicode character. 
 It returns EOF at the end of the source. It reports
 a read error by calling s.Error, if not nil; otherwise
 it prints an error message to os.Stderr. Next does not
 update the Scanner's Position field; use Pos() to
 get the current position.
 
- 
    PeekReceiver for *Scanner v1.0([])Peek returns the next Unicode character in the source without advancing 
 the scanner. It returns EOF if the scanner's position is at the last
 character of the source.
 
- 
    PosReceiver for *Scanner v1.0([])Pos returns the position of the character immediately after 
 the character or token returned by the last call to Next or Scan.
 Use the Scanner's Position field for the start position of the most
 recently scanned token.
 
- 
    ScanReceiver for *Scanner v1.0([])Scan reads the next token or Unicode character from source and returns it. 
 It only recognizes tokens t for which the respective Mode bit (1<<-t) is set.
 It returns EOF at the end of the source. It reports scanner errors (read and
 token errors) by calling s.Error, if not nil; otherwise it prints an error
 message to os.Stderr.
 
- 
    StringReceiver for *Scanner v1.0([])
- 
    TokenTextReceiver for *Scanner v1.0([])TokenText returns the string corresponding to the most recently scanned token. 
 Valid after calling Scan and in calls of Scanner.Error.
 
- 
  PositionConcrete Type v1.0Position is a value that represents a source position. 
 A position is valid if Line > 0.
 
- 
    StringReceiver for Position v1.0([])
- 
  ScannerConcrete Type v1.0A Scanner implements reading of Unicode characters and tokens from an io.Reader. 
 
- 
    StringReceiver for Scanner v1.0([])
- 
  arrayOfPositionConcrete Type v1.0Position is a value that represents a source position. 
 A position is valid if Line > 0.
 
- 
  arrayOfScannerConcrete Type v1.0A Scanner implements reading of Unicode characters and tokens from an io.Reader.