qmrparser (version 0.1.5)

streamParser: Generic interface for character processing, allowing forward and backwards translation.

Description

Generic interface for character processing. It allows going forward sequentially or backwards to a previous arbitrary position.

Each one of these functions performs an operation on or obtains information from a character sequence (stream).

Usage

streamParserNextChar(stream)
streamParserNextCharSeq(stream)
streamParserPosition(stream)
streamParserClose(stream)

Arguments

stream

object containing information about the text to be processed and, specifically, about the next character to be read

Value

streamParserNextChar and streamParserNextCharSeq

Three field list:

  • status "ok" or "eof"

  • char Character read (ok) or "" (eof)

  • stream With information about next character to be read or same position if end of file has been reached ("eof")

streamParserPosition

Three field list:

  • fileName File name or "" if the stream is not associated with a file name

  • line line number

  • linePos character to be read position within its line

  • streamPos character to be read position from the text beginning

streamParserClose

NULL

Details

  • streamParserNextChar

    Reads next character, checking if position to be read is correct.

  • streamParserNextCharSeq

    Reads next character, without checking if position to be read is correct. Implemented since it is faster than streamParserNextChar

  • streamParserPosition

    Returns information about text position being read.

  • streamParserClose

    Closes the stream

See Also

streamParserFromFileName streamParserFromString

Examples

Run this code
# NOT RUN {
stream<- streamParserFromString("Hello world")

cstream <- streamParserNextChar(stream)

while( cstream$status == "ok" ) {
    print(streamParserPosition(cstream$stream))
    print(cstream$char)
    cstream <- streamParserNextCharSeq(cstream$stream)
}

streamParserClose(stream)

# }

Run the code above in your browser using DataCamp Workspace