R/numberNatural.R

Defines functions numberNatural

Documented in numberNatural

#do not edit, edit noweb/qmrparser.nw
numberNatural <- function(action = function(s) list(type="numberNatural",value=s), 
                          error  = function(p) list(type="numberNatural",pos  =p) ) 
  
  function (stream) {
    cstream <- streamParserNextChar(stream)
    
    if ( cstream$status == "eof" || ! isDigit(cstream$char) ) return(list(status="fail",node=error(streamParserPosition(stream)),stream=stream))
    
    s <- cstream$char
    
    repeat {
      
      stream  <- cstream$stream
      cstream <- streamParserNextCharSeq(stream) 
      
      if ( cstream$status == "eof" || ! isDigit(cstream$char) )          return(list(status="ok",node=action(paste(s,collapse="")),stream=stream)) 
      
      s      <- c(s,cstream$char)
      
    }
  }

Try the qmrparser package in your browser

Any scripts or data that you put into this service are public.

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