本文整理汇总了C++中Lex::getValue方法的典型用法代码示例。如果您正苦于以下问题:C++ Lex::getValue方法的具体用法?C++ Lex::getValue怎么用?C++ Lex::getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lex
的用法示例。
在下文中一共展示了Lex::getValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: start
void Executer::start() {
Lex curLex;
while (curLex.getType() != LEX_FINISH) {
curLex = getLex();
switch (curLex.getType()) {
case LEX_NUMBER:
case LEX_STRING:
case LEX_TRUE:
case LEX_FALSE:
case POLIZ_ADDRESS:
push(curLex);
break;
case LEX_NAME: {
std::string value = curLex.getValue();
push(data[value]);
break;
}
case LEX_NOT: {
Lex val = pop();
push(Lex(LEX_STRING, val.getValue().length() ? "" : "1"));
break;
}
case LEX_ASSIGN: {
Lex val = pop(), address = pop();
data[address.getValue()] = val;
break;
}
case LEX_PLUS: {
Lex aStr = pop(), bStr = pop();
if (aStr.getType() == LEX_NUMBER && bStr.getType() == LEX_NUMBER) {
double a = std::atof(aStr.getValue().c_str()),
b = std::atof(bStr.getValue().c_str());
push(Lex(LEX_NUMBER, numToStr(a + b)));
}
else {
push(Lex(LEX_STRING, bStr.getValue() + aStr.getValue()));
}
break;
}
case LEX_MINUS: {
double a = lexToNum(pop()),
b = lexToNum(pop());
push(Lex(LEX_NUMBER, numToStr(b - a)));
break;
}
case LEX_MUL: {
double a = lexToNum(pop()),
b = lexToNum(pop());
push(Lex(LEX_NUMBER, numToStr(a * b)));
break;
}
case LEX_DIV: {
double a = lexToNum(pop()),
b = lexToNum(pop());
push(Lex(LEX_NUMBER, numToStr(b / a)));
break;
}
case POLIZ_GO: {
int pos = std::atoi(curLex.getValue().c_str());
goTo((size_t) pos);
break;
}
case POLIZ_FALSEGO: {
Lex condition = pop();
if (condition.getType() == LEX_STRING && condition.getValue() == "") {
int pos = std::atoi(curLex.getValue().c_str());
goTo((size_t) pos);
break;
}
if (condition.getType() == LEX_NUMBER)
if (condition.getValue() == "0") {
int pos = std::atoi(curLex.getValue().c_str());
goTo((size_t) pos);
break;
}
if (condition.getType() == LEX_FALSE) {
int pos = std::atoi(curLex.getValue().c_str());
goTo((size_t) pos);
break;
}
break;
}
case LEX_WRITE: {
std::cout << pop().getValue() << std::endl;
break;
}
case LEX_MORE: {
Lex a = pop(), b = pop();
if (a.getType() == LEX_FALSE && b.getType() == LEX_TRUE ||
a.getType() == LEX_NUMBER && b.getType() == LEX_NUMBER && lexToNum(a) < lexToNum(b))
push(Lex(LEX_TRUE, "1"));
else
push(Lex(LEX_FALSE, "0"));
break;
//.........这里部分代码省略.........