File MIES_SweepFormula_Parser.ipf

SFP Sweep formula parser

Functions

variable SFP_ParseFormulaToJSON(string formula)
static string SFP_StringifyState(variable state)
static string SFP_StringifyAction(variable action)
static variable SFP_LogParserState(string token, variable state, variable lastState, variable lastCalculation, variable action, variable level)
variable SFP_LogParserErrorState(string msg)
static variable SFP_LogParserStateInit(string formula)
variable SFP_SaveParserStateLog()
variable SFP_FormulaParser(string formula, variable *createdArray = defaultValue, variable indentLevel = defaultValue)

serialize a string formula into JSON

Parameters:
  • formula – string formula

  • createdArray – [optional, default 0] set on recursive calls, returns boolean if parser created a JSON array

  • indentLevel – [internal use only] recursive call level, used for debug output

Returns:

a JSONid representation

static variable SFP_ParserHandleRemainingBuffer(SF_ParserData *pad, string formula, string buffer)
static std::tuple<SF_ParserData, variable, variable, variable> SFP_ParserModifyJSON(variable action, variable lastAction, variable state, string buffer, string token, variable indentLevel)
static std::tuple<variable, variable, variable> SFP_ParserGetActionFromState(variable jsonId, variable state, variable lastCalculation, variable bufferIsEmpty)
static std::tuple<variable, variable, variable> SFP_ParserGetStateFromToken(string token, variable jsonId, string buffer)
static std::tuple<string, SF_ParserData> SFP_ParserEvaluatePossibleSign()

If buffer has a sign then it is removed from buffer. If the sign was a minus then a negation is prefixed in the json.

static std::tuple<SF_ParserData> SFP_ParserAddJSON(string formula, variable indentLevel)

Parses a formula to json and puts it at jsonPath into the current json.

static std::tuple<SF_ParserData> SFP_ParserInsertNegation()
static std::tuple<SF_ParserData> SFP_ParserAdaptSubPath(string subPath)
static std::tuple<SF_ParserData> SFP_FPPutInArrayAtPath(string jsonPathArray)

Create a new empty array object, add mainId into it at path and return created json, release subId.

static std::tuple<SF_ParserData> SFP_FPAddArray(variable subId, variable arrayWasCreated)

Adds subId to mainId, if necessary puts subId into an array, release subId.

Variables

static const double SF_STATE_UNINITIALIZED = -1
static const double SF_STATE_COLLECT = 1
static const double SF_STATE_ADDITION = 2
static const double SF_STATE_SUBTRACTION = 3
static const double SF_STATE_MULTIPLICATION = 4
static const double SF_STATE_PARENTHESIS = 6
static const double SF_STATE_FUNCTION = 7
static const double SF_STATE_ARRAY = 8
static const double SF_STATE_ARRAYELEMENT = 9
static const double SF_STATE_WHITESPACE = 10
static const double SF_STATE_NEWLINE = 12
static const double SF_STATE_DIVISION = 13
static const double SF_STATE_STRING = 14
static const double SF_STATE_STRINGTERMINATOR = 15
static const double SF_ACTION_UNINITIALIZED = -1
static const double SF_ACTION_SKIP = 0
static const double SF_ACTION_COLLECT = 1
static const double SF_ACTION_LOWERORDER = 2
static const double SF_ACTION_HIGHERORDER = 3
static const double SF_ACTION_ARRAYELEMENT = 4
static const double SF_ACTION_PARENTHESIS = 5
static const double SF_ACTION_FUNCTION = 6
static const double SF_ACTION_ARRAY = 7
static const string SF_PARSER_REGEX_SIGNED_NUMBER = "^(?i)[+-]?[0-9]+(?:\.[0-9]+)?(?:[\+-]?E[0-9]+)?$"
static const string SF_PARSER_REGEX_QUOTED_STRING = "^\".*\"$"
static const string SF_PARSER_REGEX_SIGNED_PARENTHESIS = "^(?i)[+-]?\\([\s\S]*$"
static const string SF_PARSER_REGEX_SIGNED_FUNCTION = "^(?i)[+-]?[A-Za-z]+"
static const string SF_PARSER_REGEX_OTHER_VALID_CHARS = "[A-Za-z0-9_\.:;=!$]"
struct SF_ParserData

Public Members

variable jsonId
string jsonPath