ParseCpp#

class mkShapesRDF.lib.parse_cpp.ParseCpp[source][source]#

Bases: object

A utility class to parse C++ expression, replace variables and format back to a C++ expression.

Methods

RVecExpression(_type)

Creates a string for RVec with the specified _type

format(parsedS)

Format back a parsed C++ expression to a string.

listOfVariables(parsedS)

Return the list of variables in a parsed C++ expression.

parse(string)

Parse a C++ expression and return a list of strings containing the expression split by the delimiters.

replace(parsedS, orig, new)

Replace a variable in a parsed C++ expression.

delimiters = [' ', '(', ')', '+', '-', '>', '<', '=', '&&', '/', '*', '.', ',', '!', '[', ']', '||']#

delimeters is a list of strings that are used to split the expression.

static parse(string)[source][source]#

Parse a C++ expression and return a list of strings containing the expression split by the delimiters.

Parameters:
stringstr

C++ expression to be parsed

Returns:
list of str

list of variables and delimiter that compose the expression

static format(parsedS)[source][source]#

Format back a parsed C++ expression to a string.

Parameters:
parsedSlist of str

list of variables and delimiters that compose the expression

Returns:
str

formatted C++ expression

static replace(parsedS, orig, new)[source][source]#

Replace a variable in a parsed C++ expression.

Parameters:
parsedSlist of str

parsed C++ expression

origstr

original variable name

newstr

new variable name

Returns:
list of str

parsed C++ expression with the variable replaced

static listOfVariables(parsedS)[source][source]#

Return the list of variables in a parsed C++ expression.

Parameters:
parsedSlist of str

parsed C++ expression

Returns:
list of str

list of variables in the parsed C++ expression

static RVecExpression(_type)[source][source]#

Creates a string for RVec with the specified _type

Parameters:
_typestr

string version of the type of the RVec

Returns:
str

string with the expression to be used for RVec<type>