Esempio n. 1
0
bool synaxErrorJudger::isSynaxErrorInSelect()
{
	bool flag = false;
	int begin = sqlExp.indexOf("from") + 4;
	int end = sqlExp.indexOf("where") - 1;
	if (end == -2) {
		end = sqlExp.indexOf(';') - 1;
	}
	if (tblName == 0) {
		tblName = new string(sqlExp.mid(begin, end - begin + 1).trimmed().toStdString());
	}
	else {
		*tblName = sqlExp.mid(begin, end - begin + 1).trimmed().toStdString();
	}
	if (selectAllWithoutCondRe.match(sqlExp).hasMatch()) {
		op = SELECT_ALL_WITHOUT_COND;
	}
	else if (selectAllWithCondRe.match(sqlExp).hasMatch()) {
		op = SELECT_ALL_WITH_COND;
		generateCondition();
	}
	else if (selectPartWithoutCondRe.match(sqlExp).hasMatch()) {
		op = SELECT_PART_WITHOUT_COND;
		generateSelectAttribute();
	}
	else if (selectPartWithCondRe.match(sqlExp).hasMatch()) {
		op = SELECT_PART_WITH_COND;
		generateSelectAttribute();
		generateCondition();
	}
	else {
		flag = true;
	}
	return flag;
}
Esempio n. 2
0
void CodeGenerator::visitEvolve(Model::EvolveItem *node)
{
  out << "if (";

  Model::ConditionItem *cond = nodeCast<Model::ConditionItem*>(node->mItem);

  if (cond)
    out << "(";

  generateTestCondition(node, out);

  if (reducesToEpsilon(node->mItem))
    {
      out << " || ";
      generateCondition(globalSystem.follow(node->mSymbol), out);
    }

  if (cond)
    out << ") && (" << cond->mCode << ")";

  out << ") {" << endl;

  GenerateLocalDeclarations gen_locals(out, mNames);
  gen_locals(node->mItem);

  out << node->mCode;

  visitNode(node->mItem);

  if (globalSystem.start.contains(node->mSymbol))
    out << "if (Token_EOF != yytoken) { return false; }" << endl;

  out << "}" << endl;
}
ObjectPropertyConditionSet generateConditionsForPropertyMissConcurrently(
    VM& vm, JSGlobalObject* globalObject, Structure* headStructure, UniquedStringImpl* uid)
{
    return generateConditions(
        vm, globalObject, headStructure, nullptr,
        [&] (Vector<ObjectPropertyCondition>& conditions, JSObject* object) -> bool {
            ObjectPropertyCondition result = generateCondition(vm, nullptr, object, uid, PropertyCondition::Absence);
            if (!result)
                return false;
            conditions.append(result);
            return true;
        }, Concurrent);
}
ObjectPropertyConditionSet generateConditionsForPropertySetterMiss(
    VM& vm, JSCell* owner, ExecState* exec, Structure* headStructure, UniquedStringImpl* uid)
{
    return generateConditions(
        vm, exec->lexicalGlobalObject(), headStructure, nullptr,
        [&] (Vector<ObjectPropertyCondition>& conditions, JSObject* object) -> bool {
            ObjectPropertyCondition result =
                generateCondition(vm, owner, object, uid, PropertyCondition::AbsenceOfSetter);
            if (!result)
                return false;
            conditions.append(result);
            return true;
        });
}
ObjectPropertyConditionSet generateConditionsForPrototypeEquivalenceConcurrently(
    VM& vm, JSGlobalObject* globalObject, Structure* headStructure, JSObject* prototype, UniquedStringImpl* uid)
{
    return generateConditions(vm, globalObject, headStructure, prototype,
        [&] (Vector<ObjectPropertyCondition>& conditions, JSObject* object) -> bool {
            PropertyCondition::Kind kind =
                object == prototype ? PropertyCondition::Equivalence : PropertyCondition::Absence;
            ObjectPropertyCondition result = generateCondition(vm, nullptr, object, uid, kind);
            if (!result)
                return false;
            conditions.append(result);
            return true;
        }, Concurrent);
}
Esempio n. 6
0
 void generateTestCondition(Model::Node *node, QTextStream& out)
 {
   if(node->kind == Model::NodeKindTerminal)
   {
     QStringList tokens;
     tokens << ((Model::TerminalItem*)node)->mName;
     generateConditionFromStrings(tokens, false, out);
   }
   else
   {
     World::NodeSet& s = globalSystem.first(node);
     
     generateCondition(s, out);
   }
 }
ObjectPropertyConditionSet generateConditionsForPrototypePropertyHitCustom(
    VM& vm, JSCell* owner, ExecState* exec, Structure* headStructure, JSObject* prototype,
    UniquedStringImpl* uid)
{
    return generateConditions(
        vm, exec->lexicalGlobalObject(), headStructure, prototype,
        [&] (Vector<ObjectPropertyCondition>& conditions, JSObject* object) -> bool {
            if (object == prototype)
                return true;
            ObjectPropertyCondition result =
                generateCondition(vm, owner, object, uid, PropertyCondition::Absence);
            if (!result)
                return false;
            conditions.append(result);
            return true;
        });
}
Esempio n. 8
0
bool synaxErrorJudger::isSynaxErrorInDelete()
{
	bool flag = false;
	if (tblName == 0) {
		tblName = new string(sqlExp.section(' ', 2, 2, QString::SectionSkipEmpty).remove(';').trimmed().toStdString());
	}
	else {
		*tblName = sqlExp.section(' ', 2, 2, QString::SectionSkipEmpty).remove(';').trimmed().toStdString();
	}
	if (deleteWithoutCondRe.match(sqlExp).hasMatch()) {
		op = DELETE_WITHOUT_COND;
	}
	else if (deleteWithCondRe.match(sqlExp).hasMatch()) {
		op = DELETE_WITH_COND;
		generateCondition();
	}
	else {
		flag = true;
	}
	return flag;
}
Esempio n. 9
0
/**
* Checks whether a breakpoint condition is syntactically valid
* and creates a breakpoint condition object if everything's OK.
*
* @param condition Condition to parse
* @param num Number of the breakpoint in the BP list the condition belongs to
* @return 0 in case of an error; 2 if everything went fine
**/
int checkCondition(const char* condition, int num)
{
	const char* b = condition;

	// Check if the condition isn't just all spaces.

	int onlySpaces = 1;

	while (*b)
	{
		if (*b != ' ')
		{
			onlySpaces = 0;
			break;
		}

		++b;
	}


	// If there's an actual condition create the BP condition object now

	if (*condition && !onlySpaces)
	{
		Condition* c = generateCondition(condition);

		// Remove the old breakpoint condition before adding a new condition.
		if (watchpoint[num].cond)
		{
			freeTree(watchpoint[num].cond);
			free(watchpoint[num].condText);
			watchpoint[num].cond = 0;
			watchpoint[num].condText = 0;
		}

		// If the creation of the BP condition object was succesful
		// the condition is apparently valid. It can be added to the
		// breakpoint now.

		if (c)
		{
			watchpoint[num].cond = c;
			watchpoint[num].condText = (char*)malloc(strlen(condition) + 1);
            if (!watchpoint[num].condText)
                return 0;
			strcpy(watchpoint[num].condText, condition);
		}
		else
		{
			watchpoint[num].cond = 0;
		}

		return watchpoint[num].cond == 0 ? 2 : 0;
	}
	else
	{
		// Remove the old breakpoint condition
		if (watchpoint[num].cond)
		{
			freeTree(watchpoint[num].cond);
			free(watchpoint[num].condText);
			watchpoint[num].cond = 0;
			watchpoint[num].condText = 0;
		}
		return 0;
	}
}
ObjectPropertyCondition generateConditionForSelfEquivalence(
    VM& vm, JSCell* owner, JSObject* object, UniquedStringImpl* uid)
{
    return generateCondition(vm, owner, object, uid, PropertyCondition::Equivalence);
}