Exemplo n.º 1
0
Task * pC()
{
	Task * smpl = newTask();

	clearLexList(pSt.list);

	if (cur_l->type != LEX_WORD)
	{
		setParserError(PE_EXPECTED_WORD);
		delTask(&smpl);
		return NULL;
	}

	addLex(pSt.list, pSt.l);

	for(;;)
	{
		if (gl())
		{
			clearLexList(pSt.list);
			delTask(&smpl);
			return NULL;
		}

		if (cur_l->type == LEX_WORD)
			addLex(pSt.list, pSt.l);
		else
			break;
	}

	genArgVector(smpl, pSt.list);

	return smpl;
}
Exemplo n.º 2
0
Task * pT()
{
	Task * task = NULL;

	if (cur_l->type == LEX_EOL)
	{
		waitLex();
		return NULL;
	}
	else if (cur_l->type == LEX_EOF)
		return NULL;

	task = pC();

	if (cur_l->type != LEX_EOL &&
		cur_l->type != LEX_EOF)
	{
		setParserError(PE_UNEXPECTED_END_OF_COMMAND);
		delTask(&task);
		return NULL;
	}

	waitLex();

	return task;
}
Exemplo n.º 3
0
static void error(GMarkupParseContext* /*context*/,
                  GError*              error,
                  gpointer             user_data)
{
    SimpleXmlParser *parser = (SimpleXmlParser*)user_data;
    setParserError(parser, error);
    parser->error(error->code, error->message);
}
Exemplo n.º 4
0
Task * pT()
{
	Task * task = NULL;
	tCmd * cmd;

	if (cur_l->type == LEX_EOL)
	{
		waitLex();
		return NULL;
	}
	else if (cur_l->type == LEX_EOF)
		return NULL;

	cmd = pS();

	if (cmd == NULL)
		return NULL;

	task = newTask();

	if (cur_l->type == LEX_BG)
	{
		if (glhard())
		{
			delTask(&task);
			delTCmd(&cmd);
			return NULL;
		}
		task->modeBG = 1;
	}

	if (cur_l->type != LEX_EOL &&
		cur_l->type != LEX_EOF)
	{
		setParserError(PE_UNEXPECTED_END_OF_COMMAND);
		delTask(&task);
		delTCmd(&cmd);
		return NULL;
	}

	task->root = cmd;
	task->cur = cmd;

	waitLex();

	return task;
}
Exemplo n.º 5
0
tCmd * puL()
{
	tCmd * cmd;

	if (cur_l->type == LEX_LPAREN)
	{
		if (glhard())
			return NULL;

		cmd = pS();

		if (cmd == NULL)
			return NULL;

		if (cur_l->type != LEX_RPAREN)
		{
			setParserError(PE_EXPECTED_RPAREN);
			delTCmd(&cmd);
			return NULL;
		}
		if (glhard())
		{
			delTCmd(&cmd);
			return NULL;
		}
	}
	else
	{
		cmd = pP();

		if (cmd == NULL)
			return NULL;
	}

	return cmd;
}
Exemplo n.º 6
0
tCmd * pC()
{
	tCmd * cmd;
	simpleCmd * smpl = newCommand();

	clearLexList(pSt.list);

	if (cur_l->type != LEX_WORD)
	{
		setParserError(PE_EXPECTED_WORD);
		delCommand(&smpl);
		return NULL;
	}

	addLex(pSt.list, pSt.l);

	for(;;)
	{
		if (gl())
		{
			clearLexList(pSt.list);
			delCommand(&smpl);
			return NULL;
		}

		if (cur_l->type == LEX_WORD)
			addLex(pSt.list, pSt.l);
		else if (cur_l->type == LEX_REDIRECT_INPUT ||
			cur_l->type == LEX_REDIRECT_OUTPUT ||
			cur_l->type == LEX_REDIRECT_OUTPUT_APPEND)
		{
			int type = cur_l->type;
			if (glhard())
			{
				clearLexList(pSt.list);
				delCommand(&smpl);
				return NULL;
			}

			if (cur_l->type != LEX_WORD)
			{
				setParserError(PE_EXPECTED_WORD);
				if(smpl->rdrInputFile != NULL)
					free(smpl->rdrInputFile);
				if(smpl->rdrOutputFile != NULL)
					free(smpl->rdrOutputFile);
				delCommand(&smpl);
				delLex(cur_l);
				clearLexList(pSt.list);
				return NULL;
			}

			if (type == LEX_REDIRECT_INPUT)
			{
				if(smpl->rdrInputFile != NULL)
					free(smpl->rdrInputFile);
				smpl->rdrInputFile = cur_l->str;
			}
			else if (type == LEX_REDIRECT_OUTPUT ||
				type == LEX_REDIRECT_OUTPUT_APPEND)
			{
				if (type == LEX_REDIRECT_OUTPUT_APPEND)
					smpl->rdrOutputAppend = 1;
				else
					smpl->rdrOutputAppend = 0;

				if(smpl->rdrOutputFile != NULL)
					free(smpl->rdrOutputFile);
				smpl->rdrOutputFile = cur_l->str;
			}
		}
		else
			break;
	}

	genArgVector(smpl, pSt.list);
	smpl->file = smpl->argv[0];

	cmd = genTCmd(smpl);
	cmd->cmdType = TCMD_SIMPLE;

	return cmd;
}