Token streams

The TokenStream struct supports reading of tokenizable ASCII files

API

ExtendableGrids.TokenStreamType
mutable struct TokenStream

Tokenstream allows to read tokenized data from file without keeping the file ocntent in memory.

  • input::IOStream: Input stream
  • tokens::Vector{SubString{String}}: Array of current tokens kept in memory.
  • itoken::Int64: Position of actual token in tokens array
  • lineno::Int64: Line number in IOStream
  • comment::Char: Comment character
  • dlm::Function: Function telling if given character is a delimiter.
source
Base.eofMethod
eof(tks::TokenStream) -> Bool

Check if all tokens have been consumed.

source
ExtendableGrids.expecttokenMethod
expecttoken(tks::TokenStream, expected::String) -> Bool

Expect keyword token.

If token is missing, an UnexpectedTokenError is thrown If the token has been found, reading will continue at the position after the token found.

source
ExtendableGrids.trytokenMethod
trytoken(tks::TokenStream, expected::String) -> Bool

Try for keyword token.

It token is missing, the token read is put back into stream, a value of false is returned and the next try/gettoken command continues at the same position,

Otherwise, true is returned, and reading continues after the token found.

source