예제 #1
0
void AstMatching::generateMatchOperationsSequence() {
  extern int matcherparserparse();
  extern MatchOperationList* matchOperationsSequence;
  InitializeParser(_matchExpression);
  matcherparserparse();
  // clean up possibly existing match operations sequence
#if 0
  // TODO: proper destruction not finished yet
  if(_matchOperationsSequence)
    delete _matchOperationsSequence;
#endif
  _matchOperationsSequence=matchOperationsSequence;
  FinishParser();
}
예제 #2
0
int InfixParserTree::RunParser()
{
	//Check if the parser has been run before
	if(tree_node_list.size() != 0)
		return true;

	if(InitializeParser() == false)
	{
		logfile_manager->WriteErrorMessage("InfixParserTree", "Could not initialize parser");
		return false;
	}

	int iteration_count = 0;
	int found_parseable_expression = true;

	while(found_parseable_expression && iteration_count < 1000)
	{
		found_parseable_expression = false;

		//Parse plus/minus
		if(ParseUntilDone(found_parseable_expression, &InfixParserTree::ParsePlusMinus) == false)
		{
			logfile_manager->WriteErrorMessage("InfixParserTree", "Could not do plus-minus parsing");
			return false;
		}

		//Parse times/divide
		if(ParseUntilDone(found_parseable_expression, &InfixParserTree::ParseTimesDivide) == false)
		{
			logfile_manager->WriteErrorMessage("InfixParserTree", "Could not do times-divide parsing");
			return false;
		}

		//Parse power
		if(ParseUntilDone(found_parseable_expression, &InfixParserTree::ParsePower) == false)
		{
			logfile_manager->WriteErrorMessage("InfixParserTree", "Could not do power parsing");
			return false;
		}

		//Parse parenthesis
		if(ParseUntilDone(found_parseable_expression, &InfixParserTree::ParseParenthesis) == false)
		{
			logfile_manager->WriteErrorMessage("InfixParserTree", "Could not do parenthesis parsing");
			return false;
		}

		//Parse functions
		if(ParseUntilDone(found_parseable_expression, &InfixParserTree::ParseFunction) == false)
		{
			logfile_manager->WriteErrorMessage("InfixParserTree", "Could not do function parsing");
			return false;
		}

		iteration_count++;
	}

	if(UpdateSymbolValues() == false)
	{
		logfile_manager->WriteErrorMessage("InfixParserTree", "Could not update symbol values");
		return false;
	}

	return true;
}