Example #1
0
// ParseUnnamedScope
//------------------------------------------------------------------------------
bool BFFParser::ParseUnnamedScope( BFFIterator & iter )
{
	// find the matching bracket
	BFFIterator scopeStart( iter );
	if ( iter.ParseToMatchingBrace( BFF_SCOPE_OPEN, BFF_SCOPE_CLOSE ) == false )
	{
		Error::Error_1025_MissingScopeCloseToken( scopeStart, nullptr );
		return false;
	}

	// create stack for scope
	BFFStackFrame stackFrame;

	// parse the scoped part
	BFFParser subParser;
	BFFIterator subIter( scopeStart );
	subIter++; // skip opening token
	subIter.SetMax( iter.GetCurrent() ); // limit to closing token
	if ( subParser.Parse( subIter ) == false )
	{
		return false;
	}

	iter++; // skip closing }

	return true;
}
Example #2
0
command parseScopeCmd(void){
	command cmdIn=CMD_ERR;
	uint8_t error=0;
	//try to parse command while buffer is not empty 

///////		do{ 
		cmdIn = giveNextCmd();
		switch(cmdIn){
			case CMD_SCOPE_TRIG_MODE://set trigger mode
				cmdIn = giveNextCmd();
				if(isScopeTrigMode(cmdIn)){
					if(cmdIn == CMD_MODE_NORMAL){
						scopeSetTriggerMode(TRIG_NORMAL);
					}else if(cmdIn == CMD_MODE_AUTO){
						scopeSetTriggerMode(TRIG_AUTO);
					}else if(cmdIn == CMD_MODE_SINGLE){
						scopeSetTriggerMode(TRIG_SINGLE);
					}
				}else{
					cmdIn = CMD_ERR;
					error = SCOPE_INVALID_FEATURE_PARAM;
				}
			break;
				
			case CMD_SCOPE_TRIG_EDGE: //set trigger edge
				cmdIn = giveNextCmd();
				if(isScopeTrigEdge(cmdIn)){
					if(cmdIn == CMD_EDGE_RISING){
						scopeSetTriggerEdge(EDGE_RISING);
					}else if(cmdIn == CMD_EDGE_FALLING){
						scopeSetTriggerEdge(EDGE_FALLING);
					}
				}else{
					cmdIn = CMD_ERR;
					error = SCOPE_INVALID_FEATURE_PARAM;
				}
			break;		
				
			case CMD_SCOPE_CHANNELS: //set number of channels
				cmdIn = giveNextCmd();
				if(isChannel(cmdIn)){
					if(cmdIn == CMD_CHANNELS_1){
						error=scopeSetNumOfChannels(1);
					}else if(cmdIn == CMD_CHANNELS_2){
						error=scopeSetNumOfChannels(2);
					}else if(cmdIn == CMD_CHANNELS_3){
						error=scopeSetNumOfChannels(3);
					}else if(cmdIn == CMD_CHANNELS_4){
						error=scopeSetNumOfChannels(4);
					}
				}else{
					cmdIn = CMD_ERR;
					error = SCOPE_INVALID_FEATURE_PARAM;
				}
			break;
				
			case CMD_SCOPE_TRIG_CHANNEL: //set trigger channel
				cmdIn = giveNextCmd();
				if(isChannel(cmdIn)){
					if(cmdIn == CMD_CHANNELS_1){
						error=scopeSetTrigChannel(1);
					}else if(cmdIn == CMD_CHANNELS_2){
						error=scopeSetTrigChannel(2);
					}else if(cmdIn == CMD_CHANNELS_3){
						error=scopeSetTrigChannel(3);
					}else if(cmdIn == CMD_CHANNELS_4){
						error=scopeSetTrigChannel(4);
					}
				}else{
					cmdIn = CMD_ERR;
					error = SCOPE_INVALID_FEATURE_PARAM;
				}
			break;
				
			case CMD_SCOPE_DATA_DEPTH: //set data bit depth
				cmdIn = giveNextCmd();
				if(isScopeDataDepth(cmdIn)){
					if(cmdIn == CMD_DATA_DEPTH_12B){
						error=scopeSetDataDepth(12);
					}else if(cmdIn == CMD_DATA_DEPTH_10B){
						error=SCOPE_UNSUPPORTED_RESOLUTION;
					}else if(cmdIn == CMD_DATA_DEPTH_8B){
						error=scopeSetDataDepth(8);
					}else if(cmdIn == CMD_DATA_DEPTH_6B){
						error=SCOPE_UNSUPPORTED_RESOLUTION;
					}
				}else{
					cmdIn = CMD_ERR;
					error = SCOPE_INVALID_FEATURE_PARAM;
				}
			break;
				
			case CMD_SCOPE_SAMPLING_FREQ: //set sampling frequency
				cmdIn = giveNextCmd();
				if(isScopeFreq(cmdIn)){
					if(cmdIn == CMD_FREQ_1K){
						error=scopeSetSamplingFreq(1000);
					}else if(cmdIn == CMD_FREQ_2K){
						error=scopeSetSamplingFreq(2000);
					}else if(cmdIn == CMD_FREQ_5K){
						error=scopeSetSamplingFreq(5000);
					}else if(cmdIn == CMD_FREQ_10K){
						error=scopeSetSamplingFreq(10000);
					}else if(cmdIn == CMD_FREQ_20K){
						error=scopeSetSamplingFreq(20000);
					}else if(cmdIn == CMD_FREQ_50K){
						error=scopeSetSamplingFreq(50000);
					}else if(cmdIn == CMD_FREQ_100K){
						error=scopeSetSamplingFreq(100000);
					}else if(cmdIn == CMD_FREQ_200K){
						error=scopeSetSamplingFreq(200000);
					}else if(cmdIn == CMD_FREQ_500K){
						error=scopeSetSamplingFreq(500000);
					}else if(cmdIn == CMD_FREQ_1M){
						error=scopeSetSamplingFreq(1000000);
					}else if(cmdIn == CMD_FREQ_2M){
						error=scopeSetSamplingFreq(2000000);
					}else if(cmdIn == CMD_FREQ_5M){
						error=scopeSetSamplingFreq(5000000);
					}else if(cmdIn == CMD_FREQ_10M){
						error=scopeSetSamplingFreq(10000000);
					}
				}else{
					cmdIn = CMD_ERR;
					error = SCOPE_INVALID_FEATURE_PARAM;
				}
			break;
						
			case CMD_SCOPE_TRIG_LEVEL: //set trigger level
				cmdIn = giveNextCmd();
				if(cmdIn != CMD_END && cmdIn != CMD_ERR){
					scopeSetTrigLevel((uint16_t)cmdIn);
				}else{
					cmdIn = CMD_ERR;
					error = SCOPE_INVALID_FEATURE_PARAM;
				}
			break;
				
			case CMD_SCOPE_PRETRIGGER: //set prettriger
				cmdIn = giveNextCmd();
				if(cmdIn != CMD_END && cmdIn != CMD_ERR){
					scopeSetPretrigger((uint16_t)cmdIn);
				}else{
					cmdIn = CMD_ERR;
					error = SCOPE_INVALID_FEATURE_PARAM;
				}
			break;	
				
			case CMD_SCOPE_DATA_LENGTH: //set trigger edge
				cmdIn = giveNextCmd();
				if(isScopeNumOfSamples(cmdIn)){
					if(cmdIn == CMD_SAMPLES_100){
						error=scopeSetNumOfSamples(100);
					}else if(cmdIn == CMD_SAMPLES_200){
						error=scopeSetNumOfSamples(200);
					}else if(cmdIn == CMD_SAMPLES_500){
						error=scopeSetNumOfSamples(500);
					}else if(cmdIn == CMD_SAMPLES_1K){
						error=scopeSetNumOfSamples(1000);
					}else if(cmdIn == CMD_SAMPLES_2K){
						error=scopeSetNumOfSamples(2000);
					}else if(cmdIn == CMD_SAMPLES_5K){
						error=scopeSetNumOfSamples(5000);
					}else if(cmdIn == CMD_SAMPLES_10K){
						error=scopeSetNumOfSamples(10000);
					}else if(cmdIn == CMD_SAMPLES_20K){
						error=scopeSetNumOfSamples(20000);
					}else if(cmdIn == CMD_SAMPLES_50K){
						error=scopeSetNumOfSamples(50000);
					}else if(cmdIn == CMD_SAMPLES_100K){
						error=scopeSetNumOfSamples(100000);
					}
				}else{
					cmdIn = CMD_ERR;
					error = SCOPE_INVALID_FEATURE_PARAM;
				}
			break;
				
			case CMD_SCOPE_START: //start sampling
				scopeStart();
			break;	
			
			case CMD_SCOPE_STOP: //stop sampling
				scopeStop();
			break;	
			
			case CMD_SCOPE_NEXT: //restart sampling
				scopeRestart();
			
			break;	
			case CMD_GET_CONFIG:
				xQueueSendToBack(messageQueue, "5SendScopeConfig", portMAX_DELAY);
			break;
				
			case CMD_END:break;
			default:
				error = SCOPE_INVALID_FEATURE;
////				commsSendUint32(cmdIn);
				cmdIn = CMD_ERR;
			break;
		}
///////	}while(cmdIn != CMD_END && cmdIn != CMD_ERR && error==0);
	if(error>0){
		cmdIn=error;
	}else{
		cmdIn=CMD_END;
	}
return cmdIn;
}