Token streams
The TokenStream struct supports reading of tokenizable ASCII files
API
ExtendableGrids.TokenStream — Type
mutable struct TokenStreamTokenstream 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.
ExtendableGrids.TokenStream — Method
TokenStream(input::IOStream; comment, dlm) -> TokenStream
Create Tokenstream with IOStream argument.
sourceExtendableGrids.TokenStream — Method
TokenStream(filename::String; comment, dlm) -> TokenStream
Create Tokenstream with file name argument.
sourceExtendableGrids.UnexpectedTokenError — Type
struct UnexpectedTokenError <: ExceptionError thrown when the token expected in expect! is not there.
found::Stringexpected::Stringlineno::Int64
ExtendableGrids.destruct! — Method
ExtendableGrids.expecttoken — Method
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.
sourceExtendableGrids.gettoken — Method
gettoken(
tks::TokenStream
) -> Union{Nothing, SubString{String}}
Get next token from tokenstream.
sourceExtendableGrids.trytoken — Method
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