7 #ifndef ONCE_FPARSER_H_
8 #define ONCE_FPARSER_H_
13 #include "scribusapi.h"
15 #ifdef FUNCTIONPARSER_SUPPORT_DEBUG_OUTPUT
26 SYNTAX_ERROR=0, MISM_PARENTH, MISSING_PARENTH, EMPTY_PARENTH,
27 EXPECT_OPERATOR, OUT_OF_MEMORY, UNEXPECTED_ERROR, INVALID_VARS,
28 ILL_PARAMS_AMOUNT, PREMATURE_EOS, EXPECT_PARENTH_FUNC,
29 NO_FUNCTION_PARSED_YET,
34 int Parse(
const char* Function,
const std::string& Vars,
35 bool useDegrees =
false);
36 int Parse(
const std::string& Function,
const std::string& Vars,
37 bool useDegrees =
false);
39 void setDelimiterChar(
char);
41 const char* ErrorMsg()
const;
42 inline ParseErrorType GetParseErrorType()
const {
return parseErrorType; }
44 double Eval(
const double* Vars);
45 inline int EvalError()
const {
return evalErrorType; }
47 bool AddConstant(
const std::string& name,
double value);
48 bool AddUnit(
const std::string& name,
double value);
50 typedef double (*FunctionPtr)(
const double*);
52 bool AddFunction(
const std::string& name,
53 FunctionPtr,
unsigned paramsAmount);
56 bool RemoveIdentifier(
const std::string& name);
61 int ParseAndDeduceVariables(
const std::string&
function,
62 int* amountOfVariablesFound = 0,
63 bool useDegrees =
false);
64 int ParseAndDeduceVariables(
const std::string&
function,
65 std::string& resultVarString,
66 int* amountOfVariablesFound = 0,
67 bool useDegrees =
false);
68 int ParseAndDeduceVariables(
const std::string&
function,
69 std::vector<std::string>& resultVars,
70 bool useDegrees =
false);
85 #ifdef FUNCTIONPARSER_SUPPORT_DEBUG_OUTPUT
87 void PrintByteCode(std::ostream& dest,
bool showExpression =
true)
const;
99 ParseErrorType parseErrorType;
107 bool useDegreeConversion;
108 unsigned evalRecursionLevel;
110 const char* errorLocation;
117 bool NameExists(
const char*,
unsigned);
118 bool ParseVariables(
const std::string&);
119 int ParseFunction(
const char*,
bool);
120 const char* SetErrorType(ParseErrorType,
const char*);
122 void AddFunctionOpcode_CheckDegreesConversion(
unsigned);
123 void AddFunctionOpcode(
unsigned);
124 inline void AddMultiplicationByConst(
double value);
125 template<
typename Operation>
126 inline void AddBinaryOperationByConst();
127 inline void incStackPtr();
128 bool CompilePowi(
int);
130 const char* CompileIf(
const char*);
131 const char* CompileFunctionParams(
const char*,
unsigned);
132 const char* CompileElement(
const char*);
133 const char* CompilePossibleUnit(
const char*);
134 const char* CompilePow(
const char*);
135 const char* CompileUnaryMinus(
const char*);
136 const char* CompileMult(
const char*);
137 const char* CompileAddition(
const char*);
138 const char* CompileComparison(
const char*);
139 const char* CompileAnd(
const char*);
140 const char* CompileExpression(
const char*);
Definition: fparser.hh:19
Definition: fpoptimizer.cc:178
Definition: fparser.hh:21