symbolic

0th

Percentile

Alphanumeric token.

Recognises an alphanumeric symbol. By default, a sequence of alphanumeric, numeric and dash symbols, beginning with an alphabetical character.

Keywords
Token
Usage
symbolic (charFirst=isLetter, charRest=function(ch) isLetter(ch) || isDigit(ch) || ch == "-", action = function(s) list(type="symbolic",value=s), error  = function(p) list(type="symbolic",pos =p))
Arguments
charFirst
Predicate of valid characters as first symbol character
charRest
Predicate of valid characters as the rest of symbol characters
action
Function to be executed if recognition succeeds. Character stream making up the token is passed as parameter to this function
error
Function to be executed if recognition does not succeed. Position of streamParser obtained with streamParserPosition is passed as parameter to this function
Value

Anonymous function, returning a list.function(stream) --> list(status,node,stream) From input parameters, an anonymous function is defined. This function admits just one parameter, stream, with type streamParser, and returns a three-field list:
  • status"ok" or "fail"
  • nodeWith action or error function output, depending on the case
  • streamWith information about the input, after success or failure in recognition

Aliases
  • symbolic
Examples

# fail
stream  <- streamParserFromString("123")
( symbolic()(stream) )[c("status","node")]

# ok 
stream  <- streamParserFromString("abc123_2")
( symbolic()(stream) )[c("status","node")]

Documentation reproduced from package qmrparser, version 0.1.5, License: GPL (>= 3)

Community examples

Looks like there are no examples yet.