Пример #1
0
void Parser::addEncap(Token *out, Token *list, Token *expr, int type) {
  ExpressionListPtr expList;
  if (list->exp) {
    expList = dynamic_pointer_cast<ExpressionList>(list->exp);
  } else {
    expList = NEW_EXP0(ExpressionList);
  }
  ExpressionPtr exp;
  if (type == -1) {
    exp = expr->exp;
  } else {
    ScalarExpressionPtr scalar =
      NEW_EXP(ScalarExpression, T_ENCAPSED_AND_WHITESPACE, expr->text(), true);
    scalar->onParse(m_ar);
    exp = scalar;
  }
  expList->addElement(exp);
  out->exp = expList;
}
Пример #2
0
void Parser::onScalar(Token *out, int type, Token *scalar) {
  ScalarExpressionPtr exp;
  switch (type) {
  case T_STRING:
  case T_LNUMBER:
  case T_DNUMBER:
  case T_LINE:
  case T_FILE:
  case T_CLASS_C:
  case T_METHOD_C:
  case T_FUNC_C:
    exp = NEW_EXP(ScalarExpression, type, scalar->text());
    break;
  case T_CONSTANT_ENCAPSED_STRING:
    exp = NEW_EXP(ScalarExpression, type, scalar->text(), true);
    break;
  default:
    ASSERT(false);
  }
  exp->onParse(m_ar);
  out->exp = exp;
}