void ET::interpret(String cmd0){ // ws indicates if the previous character was a whitespace bool ws=true,ms,b;obj C=0;tString cmd{cmd0}; for(Char c:cmd){ if(exitInterpretLoop)break; if(ws)newString(0); // create a new stack with execution level 0 if(charCounter>0){ stack().push(c); if((ws=(--charCounter==0))){Aggregate a=closeStack();for(Token i:a)stack().push(i);} } else switch(c){ case '\\': // one character escape character, the code is the same for u8 u16 u32 u64 if(charLevel!=0) goto d; charCounter=1;ws=false;break; case u'«' : // comment case u'¦' : // alternating pattern string starting character case u'“' : // sequential pattern string starting character case '`' : // string starting character exists in all ssc: if(ws || charLevel>0 && c==delim ){ delim=c;++charLevel; } if(!ws) goto d; ws=false;break; case u'»':ms = delim==u'«';C=classComment;goto sec; // sequential pattern string ending character exists only in u16 and above case '|':ms = delim==u'¦';C=classPatternAny;goto sec; // alternating pattern string ending character case u'”':ms = delim==u'“';C=classPatternAll;goto sec; // alternating pattern string ending character case '\'':ms = delim==u'`';C=classString;goto sec; // string ending character sec: // a string end has been found without string start. if(!ms) goto d; if(--charLevel>0) goto d; // we have arrived to charLevel=0 closing the last ' so we have to collect the stack(). stack().Class(C); oldStack(); // if(C==classComment) stack.drop(); ws=true;break; // case L'"': // string starting and ending character // if(charLevel==0)goto ssc;else goto sec; default: if(c<0xFFF) if( (isspace(c)||iscntrl(c)) && charLevel<=0 && charCounter<=0 ) // if not continue into default { b=stack().elements()>0; tString s{closeStack()}; if(b) execute(toObj(s)); ws=true; break; }else{ d: stack().push(c);ws=false;break; } else c=c+1; } } //std::cout<<"interpret ended"<<std::endl; }
PRIMITIVE curlyClose(uWord level){ Token t,closeAction;assert0(level<=execution.l,"closing curly level higher than current level"); if(level==execution.l){ if(--paren>0){ oldStack(); }else{ t=closeStack();paren=stack().pop();execution=stack().pop(); // stack().pop2((Token&)E.level(),(Token&)E.paren()); closeAction=stack().pop();stack().push(t);execute(closeAction,true); } }else{ // the level is less than the current level, the instruction is compiled stack().push2(level,curlyCloseT); } }
/* negative error code (of the form APPLICATION_ERROR_XXX). */ int Bluetooth::initializeApplication() { int ret_val = -1; SerialPortID = 0; /* Initiailize some defaults. */ /*SerialPortID = 0; UI_Mode = UI_MODE_SELECT; LoopbackActive = FALSE; DisplayRawData = FALSE; AutomaticReadActive = FALSE; NumberofValidResponses = 0;*/ /* Try to Open the stack and check if it was successful. */ if(!openStack()){ /* The stack was opened successfully. Now set some defaults. */ /* First, attempt to set the Device to be Connectable. */ ret_val = setConnectabilityMode(cmConnectableMode); /* Next, check to see if the Device was successfully made */ /* Connectable. */ if(!ret_val) { /* Now that the device is Connectable attempt to make it */ /* Discoverable. */ ret_val = setDiscoverabilityMode(dmGeneralDiscoverableMode); /* Next, check to see if the Device was successfully made */ /* Discoverable. */ if(!ret_val) { /* Now that the device is discoverable attempt to make it*/ /* pairable. */ ret_val = setPairable(); if(!ret_val) { /* Attempt to register a HCI Event Callback. */ ret_val = HCI_Register_Event_Callback(bluetoothStackID, HCI_Event_Callback, (unsigned long)this); if(ret_val > 0) { /* Assign a NULL BD_ADDR for comparison. */ ASSIGN_BD_ADDR(NullADDR, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); /* Return success to the caller. */ ret_val = (int)bluetoothStackID; } } } } /* In some error occurred then close the stack. */ if(ret_val < 0) { /* Close the Bluetooth Stack. */ closeStack(); } } else { /* There was an error while attempting to open the Stack. */ return -1; } return ret_val; }