streamParserFromString: Creates a streamParser from a string

View source: R/streamParserFromString.R

streamParserFromStringR Documentation

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

Details

See streamParser

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

Examples

# 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)
}


qmrparser documentation built on April 24, 2022, 1:05 a.m.