qmrparser (version 0.1.5)

streamParserFromString: Creates a streamParser from a string

Description

Creates a list of functions which allow streamParser manipulation (when defined from a character string)

Usage

streamParserFromString(string)

Arguments

string

string to be recognised

Value

A list of four functions which allow stream manipulation:

streamParserNextChar

Functions which takes a streamParser as argument ant returns a list(status,char,stream)

streamParserNextCharSeq

Function which takes a streamParser as argument and returns a list(status,char,stream)

streamParserPosition

Function which takes a streamParser as argument and returns position of next character to be read

streamParserClose

Function which closes the stream

Details

See streamParser

Examples

Run this code
# NOT RUN {
# reads one character
streamParserNextChar(streamParserFromString("\U00B6"))

# reads a string
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