MCPcopy Create free account
hub / github.com/Kitware/VTK / CheckExpression

Method CheckExpression

Common/Misc/vtkFunctionParser.cxx:1877–2164  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

1875
1876//------------------------------------------------------------------------------
1877void vtkFunctionParser::CheckExpression(int& pos, char** error)
1878{
1879 if (this->FunctionMTime.GetMTime() > this->CheckMTime.GetMTime())
1880 {
1881 // Need to parse again.
1882
1883 // Reset previous error cache.
1884 this->ParseErrorPositon = -1;
1885 this->SetParseError(nullptr);
1886
1887 this->CopyParseError(pos, error);
1888 }
1889 else
1890 {
1891 this->CopyParseError(pos, error);
1892 return;
1893 }
1894
1895 this->CheckMTime.Modified();
1896
1897 this->RemoveSpaces();
1898
1899 int index = 0, parenthesisCount = 0, currentChar;
1900 int functionNumber, constantNumber;
1901 int* expectCommaOnParenthesisCount = new int[this->FunctionLength];
1902 int* expectTwoCommasOnParenthesisCount = new int[this->FunctionLength];
1903 int i;
1904
1905 for (i = 0; i < this->FunctionLength; i++)
1906 {
1907 expectCommaOnParenthesisCount[i] = 0;
1908 expectTwoCommasOnParenthesisCount[i] = 0;
1909 }
1910
1911 while (true)
1912 {
1913 currentChar = this->Function[index];
1914 bool breakToOuterLoop = false;
1915
1916 // Check for valid operand (must appear)
1917
1918 // Check for leading -
1919 if (currentChar == '-')
1920 {
1921 currentChar = this->Function[++index];
1922 if (index == this->FunctionLength)
1923 {
1924 this->ParseErrorPositon = this->FindPositionInOriginalFunction(index);
1925 this->SetParseError("Syntax error: unary minus with no operand");
1926 this->CopyParseError(pos, error);
1927 delete[] expectCommaOnParenthesisCount;
1928 delete[] expectTwoCommasOnParenthesisCount;
1929 return;
1930 }
1931 }
1932
1933 // Check for leading +
1934 if (currentChar == '+')

Callers 1

CheckSyntaxMethod · 0.95

Calls 14

CopyParseErrorMethod · 0.95
RemoveSpacesMethod · 0.95
GetMathConstantNumberMethod · 0.95
IsVariableNameMethod · 0.95
GetVariableNameLengthMethod · 0.95
GetOperandNumberMethod · 0.95
IsElementaryOperatorMethod · 0.95
from_charsFunction · 0.85

Tested by

no test coverage detected