Пример #1
0
Parse_stat MCPass::parse(MCScriptPoint &sp)
{
	Symbol_type type;

	initpoint(sp);
	if (sp.next(type) != PS_NORMAL ||
		!sp.gethandler()->hasname(sp.gettoken_nameref()))
	{
		MCperror->add(PE_PASS_NOMESSAGE, sp);
		return PS_ERROR;
	}
	if (sp.skip_token(SP_FACTOR, TT_TO) == PS_NORMAL)
	{
		if (sp.next(type) != PS_NORMAL)
		{
			MCperror->add(PE_PASS_NOMESSAGE, sp);
			return PS_ERROR;
		}
		all = True;
	}
	if (sp.gethandler() -> isprivate())
	{
		MCperror -> add(PE_PRIVATE_BADPASS, sp);
		return PS_ERROR;
	}
	return PS_NORMAL;
}
Пример #2
0
Parse_stat MCDo::parse(MCScriptPoint &sp)
{
	initpoint(sp);
	h = sp.gethandler();
	if (sp.parseexp(False, True, &source) != PS_NORMAL)
	{
		MCperror->add(PE_DO_BADEXP, sp);
		return PS_ERROR;
	}
	
	if (sp.skip_token(SP_FACTOR, TT_IN, PT_IN) == PS_NORMAL)
	{
		if (sp.skip_token(SP_SUGAR, TT_UNDEFINED, SG_BROWSER) == PS_NORMAL)
			browser = True;
		else if (sp.skip_token(SP_SUGAR, TT_UNDEFINED, SG_CALLER) == PS_NORMAL)
			caller = true;
		else
		{
			MCperror->add(PE_DO_BADENV, sp);
			return PS_ERROR;
		}
		
		return PS_NORMAL;
	}
	
	if (sp.skip_token(SP_FACTOR, TT_PREP, PT_AS) == PS_NORMAL)
	{
		if (sp.parseexp(False, True, &alternatelang) != PS_NORMAL)
		{
			MCperror->add(PE_DO_BADLANG, sp);
			return PS_ERROR;
		}
	}
	return PS_NORMAL;
}
Пример #3
0
Parse_stat MCGlobal::parse(MCScriptPoint &sp)
{
	initpoint(sp);
	while (True)
	{
		Symbol_type type;
		Parse_stat stat = sp.next(type);
		if (stat == PS_EOL)
			return PS_NORMAL;
		const LT *te;
		MCExpression *newfact = NULL;
		if (stat != PS_NORMAL || type != ST_ID
		        || sp.lookup(SP_FACTOR, te) != PS_NO_MATCH
		        || sp.lookupconstant(&newfact) == PS_NORMAL)
		{
			delete newfact;
			MCperror->add
			(PE_GLOBAL_BADNAME, sp);
			return PS_ERROR;
		}
		if (sp.gethandler() == NULL)
			sp.gethlist()->newglobal(sp.gettoken_nameref());
		else
			sp.gethandler()->newglobal(sp.gettoken_nameref());
		switch (sp.next(type))
		{
		case PS_NORMAL:
			if (type != ST_SEP)
			{
				MCperror->add
				(PE_STATEMENT_NOTSEP, sp);
				return PS_ERROR;
			}
			break;
		case PS_EOL:
		case PS_EOF:
			return PS_NORMAL;
		default:
			MCperror->add
			(PE_STATEMENT_NOTSEP, sp);
			return PS_ERROR;
		}
	}
	return PS_NORMAL;
}
Пример #4
0
Parse_stat MCExit::parse(MCScriptPoint &sp)
{
	Symbol_type type;
	const LT *te;

	initpoint(sp);
	if (sp.next(type) != PS_NORMAL
	        || sp.lookup(SP_EXIT, te) != PS_NORMAL)
	{
		if (!sp.gethandler()->hasname(sp.gettoken_nameref()))
		{
			MCperror->add(PE_EXIT_BADDEST, sp);
			return PS_ERROR;
		}
		exit = ES_EXIT_HANDLER;
	}
	else
		switch (te->which)
		{
		case ET_ALL:
			exit = ES_EXIT_ALL;
			break;
		case ET_REPEAT:
			exit = ES_EXIT_REPEAT;
			break;
		case ET_SWITCH:
			exit = ES_EXIT_SWITCH;
			break;
		case ET_TO:
			if (sp.next(type) != PS_NORMAL)
			{
				MCperror->add
				(PE_EXIT_NODEST, sp);
				return PS_ERROR;
			}
			if (sp.lookup(SP_EXIT, te) != PS_NORMAL || te->which != ET_ALL)
			{
				MCperror->add
				(PE_EXIT_BADDEST, sp);
				return PS_ERROR;
			}
			exit = ES_EXIT_ALL;
			break;
		}
	return PS_NORMAL;
}
Пример #5
0
Parse_stat MCLocaltoken::parse(MCScriptPoint &sp)
{
	initpoint(sp);
	while (True)
	{
		Symbol_type type;
		Parse_stat stat = sp.next(type);
		if (stat == PS_EOL)
			return PS_NORMAL;
		const LT *te;
		MCExpression *newfact = NULL;
		if (stat != PS_NORMAL || type != ST_ID
		        || sp.lookup(SP_FACTOR, te) != PS_NO_MATCH
		        || sp.lookupconstant(&newfact) == PS_NORMAL)
		{
			delete newfact;
			MCperror->add(PE_LOCAL_BADNAME, sp);
			return PS_ERROR;
		}

		MCAutoNameRef t_token_name;
		/* UNCHECKED */ t_token_name . Clone(sp . gettoken_nameref());

		MCExpression *e = NULL;
		MCVarref *v = NULL;
		if (sp.gethandler() == NULL)
			if (constant)
				sp.gethlist()->findconstant(t_token_name, &e);
			else
				sp.gethlist()->findvar(t_token_name, false, &v);
		else
			if (constant)
				sp.gethandler()->findconstant(t_token_name, &e);
			else
				sp.gethandler()->findvar(t_token_name, &v);
		if (e != NULL || v != NULL)
		{
			MCperror->add(PE_LOCAL_SHADOW, sp);
			delete v;
			delete e;
			return PS_ERROR;
		}

		MCVariable *tmp;
		for (tmp = MCglobals ; tmp != NULL ; tmp = tmp->getnext())
			if (tmp -> hasname(t_token_name))
				if (MCexplicitvariables)
				{
					MCperror->add(PE_LOCAL_SHADOW, sp);
					return PS_ERROR;
				}

		MCVarref *tvar = NULL;
		MCString init;
		bool initialised = false;
		if (sp.skip_token(SP_FACTOR, TT_BINOP, O_EQ) == PS_NORMAL)
		{
			if (sp.next(type) != PS_NORMAL || MCexplicitvariables && type != ST_LIT
			        && type != ST_NUM)
			{
				if (constant)
					MCperror->add(PE_CONSTANT_BADINIT, sp);
				else
					MCperror->add(PE_LOCAL_BADINIT, sp);
				return PS_ERROR;
			}
			if (type == ST_MIN)
			{ // negative initializer
				const char *sptr = sp.gettoken().getstring();
				if (sp.next(type) != PS_NORMAL || type != ST_NUM)
				{
					if (constant)
						MCperror->add(PE_CONSTANT_BADINIT, sp);
					else
						MCperror->add(PE_LOCAL_BADINIT, sp);
					return PS_ERROR;
				}
				uint4 l = sp.gettoken().getstring() + sp.gettoken().getlength() - sptr;
				init.set(sptr, l);
			}
			else
				init = sp.gettoken();

			initialised = true;
		}
		else if (constant)
			{
				MCperror->add(PE_CONSTANT_NOINIT, sp);
				return PS_ERROR;
			}
			else
				init = NULL;

		MCAutoNameRef t_init_name;
		if (initialised)
			/* UNCHECKED */ t_init_name . CreateWithOldString(init);
		else
			t_init_name . Clone(kMCEmptyName);

		if (sp.gethandler() == NULL)
		{
			if (constant)
				sp.gethlist()->newconstant(t_token_name, t_init_name);
			else if (sp.gethlist()->newvar(t_token_name, t_init_name, &tvar, initialised) != PS_NORMAL)
				{
					MCperror->add(PE_LOCAL_BADNAME, sp);
					return PS_ERROR;
				}

		}
		else if (constant)
			sp.gethandler()->newconstant(t_token_name, t_init_name);
		else if (sp.gethandler()->newvar(t_token_name, t_init_name, &tvar) != PS_NORMAL)
				{
					MCperror->add(PE_LOCAL_BADNAME, sp);
					return PS_ERROR;
				}

		delete tvar;

		switch (sp.next(type))
		{
		case PS_NORMAL:
			if (type != ST_SEP)
			{
				MCperror->add(PE_STATEMENT_NOTSEP, sp);
				return PS_ERROR;
			}
			break;
		case PS_EOL:
		case PS_EOF:
			return PS_NORMAL;
		default:
			MCperror->add(PE_STATEMENT_NOTSEP, sp);
			return PS_ERROR;
		}
	}
	return PS_NORMAL;
}