MCPcopy Create free account
hub / github.com/XRay3D/GERBER_X3 / functionVariable

Method functionVariable

GTE_Win/gerber/mathparser.cpp:82–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80}
81
82Result MathParser::functionVariable(QString s) //throws Exception
83{
84 QString f;
85 int i = 0;
86 int sign = 1;
87 if (s.startsWith('-')) {
88 sign = -1;
89 s.remove(0, 1);
90 }
91 // ищем название функции или переменной
92 // имя обязательно должна начинаться с буквы
93 while (i < s.length() && ((s.at(i).isLetter() || s.at(i) == '$') || (s.at(i).isDigit() && i > 0))) {
94 //while (i < s.length() && (s.at(i).isLetter() || (s.at(i).isDigit() && i > 0))) {
95 f += s.at(i);
96 i++;
97 }
98 if (!f.isEmpty()) { // если что-нибудь нашли
99 if (s.length() > i && s.at(i) == '(') { // и следующий символ скобка значит - это функция
100 Result r = bracket(s.mid(f.length()));
101 return processFunction(f, r);
102 } else // иначе - это переменная
103 return Result(getVariable(f) * sign, s.mid(f.length()));
104 }
105 return num(s);
106}
107
108Result MathParser::mulDiv(QString s) //throws Exception
109{

Callers

nothing calls this directly

Calls 4

isEmptyMethod · 0.80
midMethod · 0.80
ResultClass · 0.70
removeMethod · 0.45

Tested by

no test coverage detected