Global

Methods

formatParserError(er, data)

format a parser error
Parameters:
Name Type Description
er instance of ParserError
data the string that was being parsed.
Source:
Returns:
the formatted message

getSkipWhitespaceFunction()

Source:
Returns:
function that skips whitespaces

makeAlternativeParser(arrayOfParsers, name, forwardWithIndex)

returns parser that must requires one of the argument parsers to math the input
Parameters:
Name Type Default Description
arrayOfParsers array of argument parsers, tries to apply each of them, consecutively.
name AlternativeParser optional name of the parser (for more readable error messages)
forwardWithIndex false
Source:
Returns:
parsing function that receives a State object for the current position within the input and returns the next state.

makeConsumeAll(nestedParser)

returns parser that must consume all of the input
Parameters:
Name Type Description
nestedParser
Source:
Returns:
parsing function that receives a State object for the current position within the input and returns the next state.

makeForwarder()

returns a forwarding object, - the inner parser can be set later on by calling the setInner(parser) member function. - the forwarded parser is called by the forward() member function. This construct is used to express recursive grammars.
Source:
Returns:
the result of the forwarded function.

makeOptParser(parser, name)

returns parser that applies the argument parser at least once
Parameters:
Name Type Default Description
parser
name OptParser optional name of the parser (for more readable error messages)
Source:
Returns:
parsing function that receives a State object for the current position within the input and returns the next state.*

makeRegexParser(regex, name)

Returns a parser that can matches/consumes a given regular expression
Parameters:
Name Type Default Description
regex the regex to match
name null optional name of the parser (for more readable error messages)
Source:
Returns:
is setKeepLocationWithToken - returns a list [ "", offset_of_token ] , else the token string is returned.

makeRepetitionParser(parser, minMatching, maxMatching, name, concat)

returns parser that applies argument parser repeatedly
Parameters:
Name Type Default Description
parser argument parsing function
minMatching 1 number of minimal matches (default 1)
maxMatching number of maximum allowed matches, -1 - no limit
name RepetitionParser optional name of the parser (for more readable error messages)
concat false if not true: result of each parser is pushed to result array. (default value). if set: result of each parser is concatenated to the result array
Source:
Returns:
a list with the results returned by each nested parser invocation

makeRepetitionRecClause(parserMandatory, parserRepetition, title, concat)

returns parser that applies argument parser repeatedly
Parameters:
Name Type Default Description
parserMandatory argument parsing function
parserRepetition argument parsing function
title RecursiveClause optional name of the parser (for more readable error messages)
concat false if not true: result of each parser is pushed to result array. (default value). if set: result of each parser is concatenated to the result array
Source:
Returns:
a list with the results returned by each nested parser invocation

makeSequenceParser(arrayOfParsers, title, concat, clearError)

returns parser that applies all argument parsers sequentially. The parser succeeds if all argument parsers succeeded to parse their input.
Parameters:
Name Type Default Description
arrayOfParsers array of argument parsers, each one applied after the previous one.
title SequenceParser optional name of the parser (for more readable error messages)
concat false if not true: result of each parser is pushed to result array. (default value). if set: result of each parser is concatenated to the result array
clearError true set to true if the last term is an optional sequence.
Source:
Returns:
an array with the results returned by each of the sequence parser.

makeTokenParser(token)

returns parser that consumes argument token string
Parameters:
Name Type Description
token
Source:
Returns:
is setKeepLocationWithToken - returns a list [ "", offset_of_token ] , else the token string is returned.

makeTransformer(nestedParser, transformResult)

returns parser that applies the argument parser to the input, then it calls the argument function to transform the result
Parameters:
Name Type Description
nestedParser nested parser
transformResult transformation function, receives result of nested parser as input.
Source:
Returns:
return the result of the transformResult parser

parseString(parser)

Applies the parser on an input string.
Parameters:
Name Type Description
parser a parser constructed by any of the makeXXXparser functions
Source:
Throws:
ParserError - in case of syntax error. also see formatParserError function.
Returns:
the result of the applied parser

setKeepLocationWithToken(on)

Keep location with return value of token parsers. If set/true: the token functions return a list of [
Parameters:
Name Type Description
on boolean true - enable tracing. (default: off)
Source:

setSkipWhitespaceFunction(argFunction)

set function that is called in order to skip whitespaces this can be used to skip comments as well
Parameters:
Name Type Description
argFunction function that skips whitespaces. The function gets a State object as parameter and advances the pos member)
Source:

setTrace(on)

Enable tracing of the parser. This function must be called before calling any of the parser generating functions (like makeSequenceParser, etc.)
Parameters:
Name Type Description
on boolean true - enable tracing. (default: off)
Source: