示例#1
0
void parse_data(char *data, char *end)
{
	char *token_alloc;      // allocated memory for tokens
	
	killscript = false;     // dont kill the script straight away
	
	// allocate space for the tokens
	token_alloc = new char[current_script->len + T_MAXTOKENS];
	
	prev_section = NULL;  // clear it
	
	while(*rover)   // go through the script executing each statement
    {
		// past end of script?
		if(rover > end)
			break;
		
		// reset the tokens before getting the next line
		tokens[0] = token_alloc;
		
		prev_section = current_section; // store from prev. statement
		
		// get the line and tokens
		get_tokens(rover);
		
		if(killscript) break;
		
		if(!num_tokens)
		{
			if(current_section)       // no tokens but a brace
			{
				// possible } at end of loop:
				// refer to spec.c
				spec_brace();
			}
			
			continue;  // continue to next statement
		}
		
		if(script_debug) print_tokens();   // debug
		run_statement();         // run the statement
    }
	delete token_alloc;
}
示例#2
0
void FParser::Run(char *rover, char *data, char *end)
{
	Rover = rover;
	try
	{
		PrevSection = NULL;  // clear it
		
		while(*Rover)   // go through the script executing each statement
		{
			// past end of script?
			if(Rover > end)
				break;
			
			PrevSection = Section; // store from prev. statement
			
			// get the line and tokens
			GetTokens(Rover);
			
			if(!NumTokens)
			{
				if(Section)       // no tokens but a brace
				{
					// possible } at end of loop:
					// refer to spec.c
					spec_brace();
				}
				
				continue;  // continue to next statement
			}
			
			if(script_debug) PrintTokens();   // debug
			RunStatement();         // run the statement
		}
	}
	catch (const CFsError &err)
	{
		ErrorMessage(err.msg);
	}
	catch (const CFsTerminator &)
	{
		// The script has signalled that it wants to be terminated in an orderly fashion.
	}
}