void Toolbar::mouseMoved(sf::Vector2i mousePosition){ if(mousePosition.y <= normalPosition.y){ retract(true); } else if(mousePosition.y > position.y + size.y){ retract(false); } }
/** * Initialization code for teleop mode should go here. * * Use this method for initialization code which will be called each time * the robot enters teleop mode. */ void RobotDemo::TeleopInit() { s1Status=true; s2Status=true; s3Status=true; retract(s3,s3Status); retract(s1,s1Status); spinnerStatusLeft=true; spinnerStatusRight=true; compressor->Start(); return; }
static int charliteral(int c) { if(!bCanInsertSymbol) { //maks: solve the error when colorize "oi/oi" WASLITERAL = 0; return c; } if (c == '\\') { switch ((c = EiC_nextchar())) { case 'n': c = '\n'; break; /* newline */ case 't': c = '\t'; break; /* tabspace */ case 'v': c = '\v'; break; /* vertical tab */ case 'b': c = '\b'; break; /* backspace */ case 'r': c = '\r'; break; /* carriage return */ case 'f': c = '\f'; break; /* formfeed */ case 'a': c = '\a'; break; /* bell */ case '\\': c = '\\'; break; /* backslash */ case '\'': c = '\''; break; /* single quote */ case '"': c = '\"'; break; /* double quote */ case '?': c = '\?'; break; /* question mark */ case 'x': /* string of hex characters */ case 'X':{ int i, val = 0; while ((i = gethex((c = EiC_nextchar()))) > -1) { val = val * 16 + i; } retract(c); if (val > 255) EiC_error("Illegal character hex value"); c = val; } break; default: if (getoct(c) > -1) { /* octal characters */ int i, val = 0; while ((i = getoct(c)) > -1) { val = val * 8 + i; c = EiC_nextchar(); } retract(c); if (val > 255) EiC_error("Illegal character octal value"); c = val; } else EiC_error("Illegal character escape sequence `\\%c'", c); break; } WASLITERAL = 1; } else WASLITERAL = 0; return ((signed char )c); }
void Turret::serverProcessWaiting(DWORD in_currTime) { Parent::serverProcess(in_currTime); if (!getControlClient() && getState () == StaticBase::Enabled && isActive()) { targetsTracked = 0; Player *closePlayer = chooseTarget (); if (targetsTracked) sleepTime = manager->getCurrentTime() + 3.0; if (closePlayer) { if (state == EXTENDED) trackAndFire(closePlayer, 0.032); else extend (0.032); } else if (!targetsTracked && manager->getCurrentTime() > sleepTime) { if (state != RETRACTED) retract (0.032); } } if (!getControlClient()) updateMove (NULL, 0.032); else updateSkip++; }
void CBridges::process() { if(m_state == EXTEND) extend(); else retract(); }
static void checkExt(int c) { /* check for unsigned and long suffix */ Lseen = Useen = Fseen = 0; if (c == 'f' || c == 'F') Fseen = 1; else if (c == 'u' || c == 'U') { Useen = 1; if ((c = EiC_nextchar()) == 'l' || c == 'L') Lseen = 1; else retract(c); } else if (c == 'l' || c == 'L') Lseen = 1; else retract(c); }
/// update - should be called at 10hz void AP_LandingGear::update() { // if there is a force deploy active, disable retraction, then reset force deploy to consume it // gear will be deployed automatically because _retract_enabled is false. // this will disable retract switch until it is cycled through deploy position if ( _force_deploy){ enable(false); force_deploy(false); } if (!_retract_enabled) { // force deployment if retract is not enabled deploy(); // retract is disabled until switch is placed into deploy position to prevent accidental retraction on bootup if switch was left in retract position enable(_command_mode == LandingGear_Deploy); return; } if (_command_mode == LandingGear_Deploy){ deploy(); } if (_command_mode == LandingGear_Retract){ retract(); } }
//悔棋,p1:现在坐标,p2=为前坐标;mode=0下棋,1移棋 bool board::back(bool mode, int p1, int p2) { int current_x(0), current_y(0); data_itoxy(p1, current_x, current_y); int pre_x(0), pre_y(0); data_itoxy(p2, pre_x, pre_y); if (retract(static_cast<CHESS_COLOR>(m_curr_color[current_x][current_y] % 2), current_x, current_y)) { if (mode == 0) { //下棋 m_curr_color[current_x][current_y] = 0; pre_chess = p2; --m_chess_num; return true; } else { //移棋 m_curr_color[pre_x][pre_y] = m_curr_color[current_x][current_y]; m_curr_color[current_x][current_y] = 0; lay(static_cast<CHESS_COLOR>(m_curr_color[pre_x][pre_y] % 2), pre_x, pre_y); pre_chess = p2; return true; } } else { string c_color; switch (m_curr_color[current_x][current_y]%2) { case WHITE:c_color = "白"; break; case BLACK:c_color = "黑"; break; case NONE:c_color = "没有颜"; break; default:c_color = "未知"; break; } cout << "不能拿起在(" << current_x << ',' << current_y << ")的" << c_color << "色棋子!" << endl; return false; } }
/// initialise state of landing gear void AP_LandingGear::init() { if (_pin_deployed != -1) { hal.gpio->pinMode(_pin_deployed, HAL_GPIO_INPUT); // set pullup/pulldown to default to non-deployed state hal.gpio->write(_pin_deployed, !_pin_deployed_polarity); log_wow_state(wow_state_current); } if (_pin_weight_on_wheels != -1) { hal.gpio->pinMode(_pin_weight_on_wheels, HAL_GPIO_INPUT); // set pullup/pulldown to default to flying state hal.gpio->write(_pin_weight_on_wheels, !_pin_weight_on_wheels_polarity); log_wow_state(wow_state_current); } switch ((enum LandingGearStartupBehaviour)_startup_behaviour.get()) { default: case LandingGear_Startup_WaitForPilotInput: // do nothing break; case LandingGear_Startup_Retract: retract(); break; case LandingGear_Startup_Deploy: deploy(); break; } }
static int fail(int ival, int c) { retract(c); switch (ival) { case RELOP: return (10); case ID: return (20); case TOKEN_FLOAT: case TOKEN_INT: return (100); } return 0; }
/// set landing gear position to retract, deploy or deploy-and-keep-deployed void AP_LandingGear::set_position(LandingGearCommand cmd) { switch (cmd) { case LandingGear_Retract: retract(); break; case LandingGear_Deploy: deploy(); break; } }
States Lexer::SwitchState_number(char c, States state, TType & a_type) { if (isdigit(c)) state = number; else { retract(); state = accept; a_type = Number; } return state; }
States Lexer::SwitchState_variable(char c, States state, TType & a_type) { if (isalpha(c) || isdigit(c) || c == '_') state = variable; else { retract(); state = accept; a_type = Variable_Token; } return state; }
// 界面可忽视: 收回移动新位置的棋子 void board::move_retract_new() { if (isSelected) { //cout << "move_retract_new error :: 之前的棋子没有放下" << endl; return; } if (who_step <= 2 * chess_num) { //cout << "move_retract_new error :: 模式不对,上一步是下棋" << endl; return; } else { isSelected = 1; // 判断棋面修改 ,相当于返回上一步 selected_color = (selected_color + 1) % 2; who_step--; selected_chess = m_before[1].top(); m_before[1].pop(); int current(m_before[0].top()), current_x(0), current_y(0); m_before[0].pop(); if (!m_before[0].empty()) pre_chess = m_before[0].top(); else { //cout << "move_retract_new error :: 为什么上一步没有棋子" << endl; return; // pre_chess = -1; } data_itoxy(current, current_x, current_y); if (m_curr_color[current_x][current_y] == m_inf || m_curr_color[current_x][current_y] == 0) { //cout << "move_retract_new error :: 这个位置没有棋了????" << endl; return; } m_chess_pos = m_curr_color[current_x][current_y]; m_curr_color[current_x][current_y] = 0; if (m_chess_pos % 2 != selected_color) { //cout << "move_retract_new error :: 这个棋子颜色和位置不一样????" << endl; } retract(m_chess_pos % 2, current_x, current_y); //cout << "在(" << current_x << ',' << current_y << ")处收回新棋子" << endl; // isSelected = 1; } }
/** * Initialization code for autonomous mode should go here. * * Use this method for initialization code which will be called each time * the robot enters autonomous mode. */ void RobotDemo::AutonomousInit() { compressor->Start(); //starting compressor to ready for teleop SmartDashboard::PutBoolean("Left-Spinner", spinnerStatusLeft); SmartDashboard::PutBoolean("Right-Spinner", spinnerStatusLeft); SmartDashboard::PutBoolean("S1-Status", s1Status); SmartDashboard::PutBoolean("S2-Status", s2Status); SmartDashboard::PutBoolean("S3-Status", s3Status); SmartDashboard::PutNumber("Compressor-Pressure", compressor->GetPressureSwitchValue()); //based on switch input on I/O tab of Driver Station--tells robot whether it //bool sideStart = true; //bool centerStartToLeft = false; //bool centerStartToRight = false; retract(s2,s2Status); //catcher arms come in first Wait(.2); retract(s3,s3Status); retract(s1,s1Status); //test this module, /*bool sideStart = ds->GetDigitalIn(1); //is starting in the middle. bool centerStartToLeft = ds->GetDigitalIn(2); //center -> left low goal bool centerStartToRight = ds->GetDigitalIn(3); //center -> right low goal */ //if(sideStart){ //either side--face right move_horizontal(-15.5); //MUST make sure robot is facing right direction!!! spinnerLeft(SPINNER_SPEED); spinnerRight(-SPINNER_SPEED); Wait(3.0); //arbitrary time -- test stopSpinnersLeft(); stopSpinnersRight(); stop(); //} }
RobotDemo::~RobotDemo() { retract(s2,s2Status); //catcher arms come in first Wait(.5); retract(s3,s3Status); retract(s1,s1Status); //get rid of pointers delete compressor; delete s3; delete s2; delete s1; delete stickOther; delete stickDrive; delete spinnerR2; delete spinnerL2; delete spinnerR1; delete spinnerL1; delete victorBR; delete victorBL; delete victorFR; delete victorFL; delete ds; }
States Lexer::SwitchState_equality(char c, States state, TType & a_type) { if (c == '=') { state = accept; a_type = Equalty; } else { retract(); state = accept; a_type = assign; } return state; }
static void EiC_stringliteral(void) { unsigned size, lastsize = 0, c; char *p=NULL; lex_str_start_pos = lex_lastpos = lex_curpos; //maks do { for (size = 0; ((c = charliteral(EiC_nextchar())) != '\0' || WASLITERAL) && !(c == '"' && !WASLITERAL) && size < BSIZE; size++) EiC_LEXEM[size] = c; if (lastsize) p = (char *) xrealloc(p, lastsize + size + 1); else p = (char *) xcalloc(size + 1, sizeof(char)); memcpy(&p[lastsize], EiC_LEXEM, size); lastsize += size; if(((c != '"') || (c == '"' && WASLITERAL)) && size == BSIZE) { p[lastsize++] = c; continue; } if (c != '"') EiC_error("String literal error"); do { c = EiC_nextchar(); if (c == '\n') lex_lastpos++, lex_lineno++; } while (WHITE(c) || c == '\n'); lex_lastpos = lex_curpos; if (!c) do c = EiC_nextchar(); while (WHITE(c)); } while (c == '"' || size == BSIZE); retract(c); p[lastsize] = '\0'; token->Val.p.sp = token->Val.p.p = p; token->Val.p.ep = p + lastsize + 1; }
//移棋第一步:选择要移动的棋子并删除它 bool board::move_select(int x, int y) { if (m_curr_color[x][y] == m_inf || m_curr_color[x][y] == 0) { //cout << "move select error :: 这个位置没有棋了????" << endl; return 0; } if (isSelected) { //cout << "move select error :: 上次的棋子还没有放下" << endl; return 0; } if (m_curr_color[x][y] % 2 != selected_color) { //cout << "move select error :: 这个颜色不允许移动" << endl; return 0; } if (m_curr_color[x][y]) { /*string c_color; switch (m_curr_color[x][y]%2) { case WHITE:c_color = "后手"; break; case BLACK:c_color = "先手"; break; case NONE:c_color = "没有"; break; default:c_color = "未知"; break; }*/ //selected_color = m_curr_color[x][y] % 2; m_chess_pos = m_curr_color[x][y]; m_curr_color[x][y] = 0; selected_chess = data_xytoi(x, y); isSelected = true; retract(selected_color, x, y); //cout << "选择在(" << x << ',' << y << ")的" << c_color << "色棋子移动" << endl; return true; } else { //cout << "错误:在(" << x << ',' << y << ")处没有棋子可供选择!" << endl; return false; } }
//移棋第一步:选择要移动的棋子并删除它 bool board::move_select(int x, int y) { if (m_curr_color[x][y]) { string c_color; switch (m_curr_color[x][y]%2) { case WHITE:c_color = "白"; break; case BLACK:c_color = "黑"; break; default:c_color = "未知"; break; } selected_color = static_cast<CHESS_COLOR>(m_curr_color[x][y] % 2); selected_chess = data_xytoi(x, y); isSelected = true; retract(selected_color, x, y); cout << "选择在(" << x << ',' << y << ")的" << c_color << "色棋子移动" << endl; return true; } else { cout << "错误:在(" << x << ',' << y << ")处没有棋子可供选择!" << endl; return false; } }
bool play(int i,int n) { //printf("play called %d\n",i); //printlava(); int j; bool flag=0; for(j=i;j<n;j++) { int x=demon[j][0]; int y=demon[j][1]; if(lava[x][y]==0) { swap(i,j); spread(x,y,i+1); if(play(i+1,n)==false) flag=1; retract(x,y,i+1); swap(i,j); if(flag==1) return true; } } return false; }
void AP_LandingGear::update(float height_above_ground_m) { if (_pin_weight_on_wheels == -1) { last_wow_event_ms = 0; wow_state_current = LG_WOW_UNKNOWN; } else { LG_WOW_State wow_state_new = hal.gpio->read(_pin_weight_on_wheels) == _pin_weight_on_wheels_polarity ? LG_WOW : LG_NO_WOW; if (wow_state_new != wow_state_current) { // we changed states, lets note the time. last_wow_event_ms = AP_HAL::millis(); log_wow_state(wow_state_new); } wow_state_current = wow_state_new; } if (_pin_deployed == -1) { last_gear_event_ms = 0; // If there was no pilot input and state is still unknown - leave it as it is if (gear_state_current != LG_UNKNOWN) { gear_state_current = (_deployed == true ? LG_DEPLOYED : LG_RETRACTED); } } else { LG_LandingGear_State gear_state_new; if (_deployed) { gear_state_new = (deployed() == true ? LG_DEPLOYED : LG_DEPLOYING); } else { gear_state_new = (deployed() == false ? LG_RETRACTED : LG_RETRACTING); } if (gear_state_new != gear_state_current) { // we changed states, lets note the time. last_gear_event_ms = AP_HAL::millis(); log_wow_state(wow_state_current); } gear_state_current = gear_state_new; } /* check for height based triggering */ int16_t alt_m = constrain_int16(height_above_ground_m, 0, INT16_MAX); if (hal.util->get_soft_armed()) { // only do height based triggering when armed if ((!_deployed || !_have_changed) && _deploy_alt > 0 && alt_m <= _deploy_alt && _last_height_above_ground > _deploy_alt) { deploy(); } if ((_deployed || !_have_changed) && _retract_alt > 0 && _retract_alt >= _deploy_alt && alt_m >= _retract_alt && _last_height_above_ground < _retract_alt) { retract(); } } _last_height_above_ground = alt_m; }
static int look(Scanner *s) { int state = 0; int c = 0; String *str_delimiter = 0; Clear(s->text); s->start_line = s->line; Setfile(s->text, Getfile(s->str)); while (1) { switch (state) { case 0: if ((c = nextchar(s)) == 0) return (0); /* Process delimiters */ if (c == '\n') { return SWIG_TOKEN_ENDLINE; } else if (!isspace(c)) { retract(s, 1); state = 1000; Clear(s->text); Setline(s->text, s->line); Setfile(s->text, Getfile(s->str)); } break; case 1000: if ((c = nextchar(s)) == 0) return (0); if (c == '%') state = 4; /* Possibly a SWIG directive */ /* Look for possible identifiers or unicode/delimiter strings */ else if ((isalpha(c)) || (c == '_') || (s->idstart && strchr(s->idstart, c))) { state = 7; } /* Look for single character symbols */ else if (c == '(') { brackets_push(s); return SWIG_TOKEN_LPAREN; } else if (c == ')') { brackets_pop(s); return SWIG_TOKEN_RPAREN; } else if (c == ';') { brackets_clear(s); return SWIG_TOKEN_SEMI; } else if (c == ',') return SWIG_TOKEN_COMMA; else if (c == '*') state = 220; else if (c == '}') return SWIG_TOKEN_RBRACE; else if (c == '{') { brackets_reset(s); return SWIG_TOKEN_LBRACE; } else if (c == '=') state = 33; else if (c == '+') state = 200; else if (c == '-') state = 210; else if (c == '&') state = 31; else if (c == '|') state = 32; else if (c == '^') state = 230; else if (c == '<') state = 60; else if (c == '>') state = 61; else if (c == '~') return SWIG_TOKEN_NOT; else if (c == '!') state = 3; else if (c == '\\') return SWIG_TOKEN_BACKSLASH; else if (c == '[') return SWIG_TOKEN_LBRACKET; else if (c == ']') return SWIG_TOKEN_RBRACKET; else if (c == '@') return SWIG_TOKEN_AT; else if (c == '$') state = 75; else if (c == '#') return SWIG_TOKEN_POUND; else if (c == '?') return SWIG_TOKEN_QUESTION; /* Look for multi-character sequences */ else if (c == '/') { state = 1; /* Comment (maybe) */ s->start_line = s->line; } else if (c == ':') state = 5; /* maybe double colon */ else if (c == '0') state = 83; /* An octal or hex value */ else if (c == '\"') { state = 2; /* A string constant */ s->start_line = s->line; Clear(s->text); } else if (c == '\'') { s->start_line = s->line; Clear(s->text); state = 9; /* A character constant */ } else if (c == '`') { s->start_line = s->line; Clear(s->text); state = 900; } else if (c == '.') state = 100; /* Maybe a number, maybe just a period */ else if (isdigit(c)) state = 8; /* A numerical value */ else state = 99; /* An error */ break; case 1: /* Comment block */ if ((c = nextchar(s)) == 0) return (0); if (c == '/') { state = 10; /* C++ style comment */ Clear(s->text); Setline(s->text, Getline(s->str)); Setfile(s->text, Getfile(s->str)); Append(s->text, "//"); } else if (c == '*') { state = 11; /* C style comment */ Clear(s->text); Setline(s->text, Getline(s->str)); Setfile(s->text, Getfile(s->str)); Append(s->text, "/*"); } else if (c == '=') { return SWIG_TOKEN_DIVEQUAL; } else { retract(s, 1); return SWIG_TOKEN_SLASH; } break; case 10: /* C++ style comment */ if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated comment\n"); return SWIG_TOKEN_ERROR; } if (c == '\n') { retract(s,1); return SWIG_TOKEN_COMMENT; } else { state = 10; } break; case 11: /* C style comment block */ if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated comment\n"); return SWIG_TOKEN_ERROR; } if (c == '*') { state = 12; } else { state = 11; } break; case 12: /* Still in C style comment */ if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated comment\n"); return SWIG_TOKEN_ERROR; } if (c == '*') { state = 12; } else if (c == '/') { return SWIG_TOKEN_COMMENT; } else { state = 11; } break; case 2: /* Processing a string */ if (!str_delimiter) { state=20; break; } if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated string\n"); return SWIG_TOKEN_ERROR; } else if (c == '(') { state = 20; } else { char temp[2] = { 0, 0 }; temp[0] = c; Append( str_delimiter, temp ); } break; case 20: /* Inside the string */ if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated string\n"); return SWIG_TOKEN_ERROR; } if (!str_delimiter) { /* Ordinary string: "value" */ if (c == '\"') { Delitem(s->text, DOH_END); return SWIG_TOKEN_STRING; } else if (c == '\\') { Delitem(s->text, DOH_END); get_escape(s); } } else { /* Custom delimiter string: R"XXXX(value)XXXX" */ if (c==')') { int i=0; String *end_delimiter = NewStringEmpty(); while ((c = nextchar(s)) != 0 && c!='\"') { char temp[2] = { 0, 0 }; temp[0] = c; Append( end_delimiter, temp ); i++; } if (Strcmp( str_delimiter, end_delimiter )==0) { Delete( end_delimiter ); /* Correct end delimiter )XXXX" occured */ Delete( str_delimiter ); str_delimiter = 0; return SWIG_TOKEN_STRING; } else { /* Incorrect end delimiter occured */ if (c == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated raw string, started with R\"%s( is not terminated by )%s\"\n", str_delimiter, str_delimiter); return SWIG_TOKEN_ERROR; } retract( s, i ); Delete( end_delimiter ); } } } break; case 3: /* Maybe a not equals */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_LNOT; else if (c == '=') return SWIG_TOKEN_NOTEQUAL; else { retract(s, 1); return SWIG_TOKEN_LNOT; } break; case 31: /* AND or Logical AND or ANDEQUAL */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_AND; else if (c == '&') return SWIG_TOKEN_LAND; else if (c == '=') return SWIG_TOKEN_ANDEQUAL; else { retract(s, 1); return SWIG_TOKEN_AND; } break; case 32: /* OR or Logical OR */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_OR; else if (c == '|') return SWIG_TOKEN_LOR; else if (c == '=') return SWIG_TOKEN_OREQUAL; else { retract(s, 1); return SWIG_TOKEN_OR; } break; case 33: /* EQUAL or EQUALTO */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_EQUAL; else if (c == '=') return SWIG_TOKEN_EQUALTO; else { retract(s, 1); return SWIG_TOKEN_EQUAL; } break; case 4: /* A wrapper generator directive (maybe) */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_PERCENT; if (c == '{') { state = 40; /* Include block */ Clear(s->text); Setline(s->text, Getline(s->str)); Setfile(s->text, Getfile(s->str)); s->start_line = s->line; } else if (s->idstart && strchr(s->idstart, '%') && ((isalpha(c)) || (c == '_'))) { state = 7; } else if (c == '=') { return SWIG_TOKEN_MODEQUAL; } else if (c == '}') { Swig_error(cparse_file, cparse_line, "Syntax error. Extraneous '%%}'\n"); exit(1); } else { retract(s, 1); return SWIG_TOKEN_PERCENT; } break; case 40: /* Process an include block */ if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated block\n"); return SWIG_TOKEN_ERROR; } if (c == '%') state = 41; break; case 41: /* Still processing include block */ if ((c = nextchar(s)) == 0) { set_error(s,s->start_line,"Unterminated code block"); return 0; } if (c == '}') { Delitem(s->text, DOH_END); Delitem(s->text, DOH_END); Seek(s->text,0,SEEK_SET); return SWIG_TOKEN_CODEBLOCK; } else { state = 40; } break; case 5: /* Maybe a double colon */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_COLON; if (c == ':') state = 50; else { retract(s, 1); return SWIG_TOKEN_COLON; } break; case 50: /* DCOLON, DCOLONSTAR */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_DCOLON; else if (c == '*') return SWIG_TOKEN_DCOLONSTAR; else { retract(s, 1); return SWIG_TOKEN_DCOLON; } break; case 60: /* shift operators */ if ((c = nextchar(s)) == 0) { brackets_increment(s); return SWIG_TOKEN_LESSTHAN; } if (c == '<') state = 240; else if (c == '=') return SWIG_TOKEN_LTEQUAL; else { retract(s, 1); brackets_increment(s); return SWIG_TOKEN_LESSTHAN; } break; case 61: if ((c = nextchar(s)) == 0) { brackets_decrement(s); return SWIG_TOKEN_GREATERTHAN; } if (c == '>' && brackets_allow_shift(s)) state = 250; else if (c == '=') return SWIG_TOKEN_GTEQUAL; else { retract(s, 1); brackets_decrement(s); return SWIG_TOKEN_GREATERTHAN; } break; case 7: /* Identifier or true/false or unicode/custom delimiter string */ if (c == 'R') { /* Possibly CUSTOM DELIMITER string */ state = 72; break; } else if (c == 'L') { /* Probably identifier but may be a wide string literal */ state = 77; break; } else if (c != 'u' && c != 'U') { /* Definitely an identifier */ state = 70; break; } if ((c = nextchar(s)) == 0) { state = 76; } else if (c == '\"') { /* Definitely u, U or L string */ retract(s, 1); state = 1000; } else if (c == 'R') { /* Possibly CUSTOM DELIMITER u, U, L string */ state = 73; } else if (c == '8') { /* Possibly u8 string */ state = 71; } else { retract(s, 1); /* Definitely an identifier */ state = 70; } break; case 70: /* Identifier */ if ((c = nextchar(s)) == 0) state = 76; else if (isalnum(c) || (c == '_') || (c == '$')) { state = 70; } else { retract(s, 1); state = 76; } break; case 71: /* Possibly u8 string */ if ((c = nextchar(s)) == 0) { state = 76; } else if (c=='\"') { retract(s, 1); /* Definitely u8 string */ state = 1000; } else if (c=='R') { state = 74; /* Possibly CUSTOM DELIMITER u8 string */ } else { retract(s, 2); /* Definitely an identifier. Retract 8" */ state = 70; } break; case 72: /* Possibly CUSTOM DELIMITER string */ case 73: case 74: if ((c = nextchar(s)) == 0) { state = 76; } else if (c=='\"') { retract(s, 1); /* Definitely custom delimiter u, U or L string */ str_delimiter = NewStringEmpty(); state = 1000; } else { if (state==72) { retract(s, 1); /* Definitely an identifier. Retract ? */ } else if (state==73) { retract(s, 2); /* Definitely an identifier. Retract R? */ } else if (state==74) { retract(s, 3); /* Definitely an identifier. Retract 8R? */ } state = 70; } break; case 75: /* Special identifier $ */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_DOLLAR; if (isalnum(c) || (c == '_') || (c == '*') || (c == '&')) { state = 70; } else { retract(s,1); if (Len(s->text) == 1) return SWIG_TOKEN_DOLLAR; state = 76; } break; case 76: /* Identifier or true/false */ if (cparse_cplusplus) { if (Strcmp(s->text, "true") == 0) return SWIG_TOKEN_BOOL; else if (Strcmp(s->text, "false") == 0) return SWIG_TOKEN_BOOL; } return SWIG_TOKEN_ID; break; case 77: /*identifier or wide string literal*/ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_ID; else if (c == '\"') { s->start_line = s->line; Clear(s->text); state = 78; } else if (c == '\'') { s->start_line = s->line; Clear(s->text); state = 79; } else if (isalnum(c) || (c == '_') || (c == '$')) state = 7; else { retract(s, 1); return SWIG_TOKEN_ID; } break; case 78: /* Processing a wide string literal*/ if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated wide string\n"); return SWIG_TOKEN_ERROR; } if (c == '\"') { Delitem(s->text, DOH_END); return SWIG_TOKEN_WSTRING; } else if (c == '\\') { if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated wide string\n"); return SWIG_TOKEN_ERROR; } } break; case 79: /* Processing a wide char literal */ if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated wide character constant\n"); return SWIG_TOKEN_ERROR; } if (c == '\'') { Delitem(s->text, DOH_END); return (SWIG_TOKEN_WCHAR); } else if (c == '\\') { if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated wide character literal\n"); return SWIG_TOKEN_ERROR; } } break; case 8: /* A numerical digit */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_INT; if (c == '.') { state = 81; } else if ((c == 'e') || (c == 'E')) { state = 82; } else if ((c == 'f') || (c == 'F')) { Delitem(s->text, DOH_END); return SWIG_TOKEN_FLOAT; } else if (isdigit(c)) { state = 8; } else if ((c == 'l') || (c == 'L')) { state = 87; } else if ((c == 'u') || (c == 'U')) { state = 88; } else { retract(s, 1); return SWIG_TOKEN_INT; } break; case 81: /* A floating pointer number of some sort */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_DOUBLE; if (isdigit(c)) state = 81; else if ((c == 'e') || (c == 'E')) state = 820; else if ((c == 'f') || (c == 'F')) { Delitem(s->text, DOH_END); return SWIG_TOKEN_FLOAT; } else if ((c == 'l') || (c == 'L')) { Delitem(s->text, DOH_END); return SWIG_TOKEN_DOUBLE; } else { retract(s, 1); return (SWIG_TOKEN_DOUBLE); } break; case 82: if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Exponent does not have any digits\n"); return SWIG_TOKEN_ERROR; } if ((isdigit(c)) || (c == '-') || (c == '+')) state = 86; else { retract(s, 2); Swig_error(cparse_file, cparse_start_line, "Exponent does not have any digits\n"); return SWIG_TOKEN_ERROR; } break; case 820: /* Like case 82, but we've seen a decimal point. */ if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Exponent does not have any digits\n"); return SWIG_TOKEN_ERROR; } if ((isdigit(c)) || (c == '-') || (c == '+')) state = 86; else { retract(s, 2); Swig_error(cparse_file, cparse_start_line, "Exponent does not have any digits\n"); return SWIG_TOKEN_ERROR; } break; case 83: /* Might be a hexadecimal or octal number */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_INT; if (isdigit(c)) state = 84; else if ((c == 'x') || (c == 'X')) state = 85; else if (c == '.') state = 81; else if ((c == 'l') || (c == 'L')) { state = 87; } else if ((c == 'u') || (c == 'U')) { state = 88; } else { retract(s, 1); return SWIG_TOKEN_INT; } break; case 84: /* This is an octal number */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_INT; if (isdigit(c)) state = 84; else if ((c == 'l') || (c == 'L')) { state = 87; } else if ((c == 'u') || (c == 'U')) { state = 88; } else { retract(s, 1); return SWIG_TOKEN_INT; } break; case 85: /* This is an hex number */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_INT; if (isxdigit(c)) state = 85; else if ((c == 'l') || (c == 'L')) { state = 87; } else if ((c == 'u') || (c == 'U')) { state = 88; } else { retract(s, 1); return SWIG_TOKEN_INT; } break; case 86: /* Rest of floating point number */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_DOUBLE; if (isdigit(c)) state = 86; else if ((c == 'f') || (c == 'F')) { Delitem(s->text, DOH_END); return SWIG_TOKEN_FLOAT; } else if ((c == 'l') || (c == 'L')) { Delitem(s->text, DOH_END); return SWIG_TOKEN_DOUBLE; } else { retract(s, 1); return SWIG_TOKEN_DOUBLE; } break; case 87: /* A long integer of some sort */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_LONG; if ((c == 'u') || (c == 'U')) { return SWIG_TOKEN_ULONG; } else if ((c == 'l') || (c == 'L')) { state = 870; } else { retract(s, 1); return SWIG_TOKEN_LONG; } break; /* A long long integer */ case 870: if ((c = nextchar(s)) == 0) return SWIG_TOKEN_LONGLONG; if ((c == 'u') || (c == 'U')) { return SWIG_TOKEN_ULONGLONG; } else { retract(s, 1); return SWIG_TOKEN_LONGLONG; } /* An unsigned number */ case 88: if ((c = nextchar(s)) == 0) return SWIG_TOKEN_UINT; if ((c == 'l') || (c == 'L')) { state = 880; } else { retract(s, 1); return SWIG_TOKEN_UINT; } break; /* Possibly an unsigned long long or unsigned long */ case 880: if ((c = nextchar(s)) == 0) return SWIG_TOKEN_ULONG; if ((c == 'l') || (c == 'L')) return SWIG_TOKEN_ULONGLONG; else { retract(s, 1); return SWIG_TOKEN_ULONG; } /* A character constant */ case 9: if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated character constant\n"); return SWIG_TOKEN_ERROR; } if (c == '\'') { Delitem(s->text, DOH_END); return (SWIG_TOKEN_CHAR); } else if (c == '\\') { Delitem(s->text, DOH_END); get_escape(s); } break; /* A period or maybe a floating point number */ case 100: if ((c = nextchar(s)) == 0) return (0); if (isdigit(c)) state = 81; else { retract(s, 1); return SWIG_TOKEN_PERIOD; } break; case 200: /* PLUS, PLUSPLUS, PLUSEQUAL */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_PLUS; else if (c == '+') return SWIG_TOKEN_PLUSPLUS; else if (c == '=') return SWIG_TOKEN_PLUSEQUAL; else { retract(s, 1); return SWIG_TOKEN_PLUS; } break; case 210: /* MINUS, MINUSMINUS, MINUSEQUAL, ARROW */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_MINUS; else if (c == '-') return SWIG_TOKEN_MINUSMINUS; else if (c == '=') return SWIG_TOKEN_MINUSEQUAL; else if (c == '>') state = 211; else { retract(s, 1); return SWIG_TOKEN_MINUS; } break; case 211: /* ARROW, ARROWSTAR */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_ARROW; else if (c == '*') return SWIG_TOKEN_ARROWSTAR; else { retract(s, 1); return SWIG_TOKEN_ARROW; } break; case 220: /* STAR, TIMESEQUAL */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_STAR; else if (c == '=') return SWIG_TOKEN_TIMESEQUAL; else { retract(s, 1); return SWIG_TOKEN_STAR; } break; case 230: /* XOR, XOREQUAL */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_XOR; else if (c == '=') return SWIG_TOKEN_XOREQUAL; else { retract(s, 1); return SWIG_TOKEN_XOR; } break; case 240: /* LSHIFT, LSEQUAL */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_LSHIFT; else if (c == '=') return SWIG_TOKEN_LSEQUAL; else { retract(s, 1); return SWIG_TOKEN_LSHIFT; } break; case 250: /* RSHIFT, RSEQUAL */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_RSHIFT; else if (c == '=') return SWIG_TOKEN_RSEQUAL; else { retract(s, 1); return SWIG_TOKEN_RSHIFT; } break; /* An illegal character */ /* Reverse string */ case 900: if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated character constant\n"); return SWIG_TOKEN_ERROR; } if (c == '`') { Delitem(s->text, DOH_END); return (SWIG_TOKEN_RSTRING); } break; default: return SWIG_TOKEN_ILLEGAL; } } }
static void get_escape(Scanner *s) { int result = 0; int state = 0; int c; while (1) { c = nextchar(s); if (c == 0) break; switch (state) { case 0: if (c == 'n') { Delitem(s->text, DOH_END); Append(s->text,"\n"); return; } if (c == 'r') { Delitem(s->text, DOH_END); Append(s->text,"\r"); return; } if (c == 't') { Delitem(s->text, DOH_END); Append(s->text,"\t"); return; } if (c == 'a') { Delitem(s->text, DOH_END); Append(s->text,"\a"); return; } if (c == 'b') { Delitem(s->text, DOH_END); Append(s->text,"\b"); return; } if (c == 'f') { Delitem(s->text, DOH_END); Append(s->text,"\f"); return; } if (c == '\\') { Delitem(s->text, DOH_END); Append(s->text,"\\"); return; } if (c == 'v') { Delitem(s->text, DOH_END); Append(s->text,"\v"); return; } if (c == 'e') { Delitem(s->text, DOH_END); Append(s->text,"\033"); return; } if (c == '\'') { Delitem(s->text, DOH_END); Append(s->text,"\'"); return; } if (c == '\"') { Delitem(s->text, DOH_END); Append(s->text,"\""); return; } if (c == '\n') { Delitem(s->text, DOH_END); return; } if (isdigit(c)) { state = 10; result = (c - '0'); Delitem(s->text, DOH_END); } else if (c == 'x') { state = 20; Delitem(s->text, DOH_END); } else { char tmp[3]; tmp[0] = '\\'; tmp[1] = (char)c; tmp[2] = 0; Delitem(s->text, DOH_END); Append(s->text, tmp); return; } break; case 10: if (!isdigit(c)) { retract(s,1); Putc((char)result,s->text); return; } result = (result << 3) + (c - '0'); Delitem(s->text, DOH_END); break; case 20: if (!isxdigit(c)) { retract(s,1); Putc((char)result, s->text); return; } if (isdigit(c)) result = (result << 4) + (c - '0'); else result = (result << 4) + (10 + tolower(c) - 'a'); Delitem(s->text, DOH_END); break; } } return; }
extern int EiC_lexan(void) { int t=0, loop; char c=0, EiC_nextchar(); #ifdef ILOOKAHEAD token = &EiC_TokenArray[EiC_TokenP]; if(EiC_TokenR > 0) { EiC_TokenR--; EiC_TokenI++; EiC_TokenP=(EiC_TokenP+1)%MAX_TOKENS; return token->Tok; } #else if (STOKEN != NOTOKEN) { STOKEN = NOTOKEN; return token->Tok; } #endif loop = 1; state = 0; while (loop) { switch (state) { case 0: lex_lastpos = lex_curpos; c = EiC_nextchar(); state = (WHITE(c) ? 0 : (c == '\n' ? lex_lineno++, 0 : (c == '<' ? t = LT, 1 : (c == '>' ? t = GT, 2 : (c == '+' ? t = '+', 3 : (c == '-' ? t = '-', 4 : (c == '|' ? t = BOR, 5 : (c == '&' ? t = AND, 6 : (c == '\''? 7 : (c == '"' ? 8 : (c == '.' ? 9 : (c == '/' ? t = '/', c = EiC_nextchar(), 50 : (c == '%' ? t = '%', c = EiC_nextchar(), 50 : (c == '*' ? t = '*', c = EiC_nextchar(), 50 : (c == '=' ? t = ASS, c = EiC_nextchar(), 50 : (c == '!' ? t = NOT, c = EiC_nextchar(), 50 : (c == '^' ? t = XOR, c = EiC_nextchar(), 50 : //(c == '~' ? t = NOTB, c = EiC_nextchar(), 50 : //maks: ~ fail(RELOP, c)))))))))))))))))); break; case 1: /* get <, <= and << */ if ((c = EiC_nextchar()) == '<') t = LSHT; else state = 50; break; case 2: /* get >, >= and >> */ if ((c = EiC_nextchar()) == '>') t = RSHT; else state = 50; break; case 3: c = EiC_nextchar(); /* get +, += or ++ */ if (c == '+') t = INC, state = 60; else state = 50; break; case 4: c = EiC_nextchar(); /* get -, -= -- */ state = 60; if (c == '-') t = DEC; else if (c == '>') t = RARROW; else state = 50; break; case 5: c = EiC_nextchar(); /* get |, |= or || */ if (c == '|') t = LOR, state = 60; else state = 50; break; case 6: c = EiC_nextchar(); /* get &, &= or && */ if (c == '&') t = LAND, state = 60; else state = 50; break; case 7:token->Val.ival = charliteral(EiC_nextchar()); /* char_constants */ t = TOKEN_CHAR; if (EiC_nextchar() != '\'') EiC_error("Missing single quote '"); state = 60; break; case 8: EiC_stringliteral(); /* string literals */ token->Tok = STR; /*return STR;*/ loop = 0; break; case 9: c = EiC_nextchar(); t = '.'; if(DIGIT(c)) state = 22; else state = 60; retract(c); break; case 10: c = EiC_nextchar(); /* identifiers and keywords */ state = (LETTER(c) ? 11 : (c == '_' ? 11 : fail(ID, c))); break; case 11: c = EiC_nextchar(); state = (LETTER(c) ? 11 : (DIGIT(c) ? 11 : (c == '_' ? 11 : 12))); break; case 12: retract(c); success(ID); /*return (token->Tok);*/ loop = 0; break; case 20: c = EiC_nextchar(); /* integers and reals */ state = (c == '0' ? 30 : (DIGIT(c) ? 21 : fail(TOKEN_INT, c))); break; case 21: c = EiC_nextchar(); state = (DIGIT(c) ? 21 : (c == '.' ? 22 : (c == 'e' ? 23 : (c == 'E' ? 23 : 25)))); break; case 22: c = EiC_nextchar(); state = (DIGIT(c) ? 22 : (c == 'e' ? 23 : (c == 'E' ? 23 : 26))); break; case 23: c = EiC_nextchar(); state = (c == '+' ? 24 : (c == '-' ? 24 : (DIGIT(c) ? 24 : fail(TOKEN_FLOAT, c) /* ??? */ ))); break; case 24: c = EiC_nextchar(); state = (DIGIT(c) ? 24 : 26); break; case 25: checkExt(c); success(TOKEN_INT); /*return (token->Tok);*/ loop = 0; break; case 26: checkExt(c); success(TOKEN_FLOAT); /*return (token->Tok);*/ loop = 0; break; case 27: checkExt(c); success(HEX); /*return (token->Tok);*/ loop = 0; break; case 28: checkExt(c); success(OCTAL); /*return (token->Tok);*/ loop = 0; break; case 30: /* check for octal and hex numbers */ if ((c = EiC_nextchar()) == 'x' || c == 'X') { while (gethex((c = EiC_nextchar())) > -1); state = 27; break; } if (c != '.' && c != 'e' && c != 'E') { while (getoct(c) > -1) c = EiC_nextchar(); state = 28; break; } retract(c); state = 21; break; case 50: /* mix with equal's */ if (c == '=') switch (t) { case '+': t = ADDEQ; break; /* += */ case '-': t = SUBEQ; break; /* -= */ case '/': t = DIVEQ; break; /* /= */ case '*': t = MULEQ; break; /* *= */ case '%': t = MODEQ; break; /* %= */ case ASS: t = EQ; break; /* == */ case GT: t = GE; break; /* >= */ case LT: t = LE; break; /* <= */ case NOT: t = NE; break; /* != */ case RSHT:t = RSHTEQ; break; /* >>= */ case LSHT:t = LSHTEQ; break; /* <<= */ case AND: t = ANDEQ; break; /* &= */ case BOR: t = BOREQ; break; /* |= */ case XOR: t = XOREQ; break; /* ^= */ //case NOTB: t = NOTBEQ; break; /* maks ~= */ default: retract(c); } else if(c == '/' && t == '/') //maks { //C++ comment //Only for colorize //Comments are removed by preprocessor before parser do { c = EiC_nextchar(); } while(c && c != '\n'); retract(c); success(MISC); token->Tok = TOKEN_COMMENT; loop = 0; break; } else retract(c); state = 60; break; case 60: success(MISC); token->Tok = t; /*return (token->Tok);*/ loop = 0; break; case 100: token->Tok = EiC_nextchar(); /*return (token->Tok);*/ loop = 0; break; } } #ifdef ILOOKAHEAD if(EiC_TokenI<MAX_TOKENS) EiC_TokenI++; EiC_TokenP = (EiC_TokenP +1)%MAX_TOKENS; #endif return token->Tok; }
static int look(SwigScanner *s) { int state; int c = 0; state = 0; Clear(s->text); Setline(s->text, Getline(s->str)); Setfile(s->text, Getfile(s->str)); while(1) { switch(state) { case 0 : if((c = nextchar(s)) == 0) return(0); /* Process delimeters */ if (c == '\n') { return SWIG_TOKEN_ENDLINE; } else if (!isspace(c)) { retract(s,1); state = 1000; Clear(s->text); Setline(s->text, Getline(s->str)); Setfile(s->text, Getfile(s->str)); } break; case 1000: if ((c = nextchar(s)) == 0) return (0); if (c == '%') state = 4; /* Possibly a SWIG directive */ /* Look for possible identifiers */ else if ((isalpha(c)) || (c == '_') || (strchr(s->idstart,c))) state = 7; /* Look for single character symbols */ else if (c == '(') return SWIG_TOKEN_LPAREN; else if (c == ')') return SWIG_TOKEN_RPAREN; else if (c == ';') return SWIG_TOKEN_SEMI; else if (c == ',') return SWIG_TOKEN_COMMA; else if (c == '*') return SWIG_TOKEN_STAR; else if (c == '}') return SWIG_TOKEN_RBRACE; else if (c == '{') return SWIG_TOKEN_LBRACE; else if (c == '=') state = 33; else if (c == '+') return SWIG_TOKEN_PLUS; else if (c == '-') return SWIG_TOKEN_MINUS; else if (c == '&') state = 31; else if (c == '|') state = 32; else if (c == '^') return SWIG_TOKEN_XOR; else if (c == '<') state = 60; else if (c == '>') state = 61; else if (c == '~') return SWIG_TOKEN_NOT; else if (c == '!') state = 3; else if (c == '\\') return SWIG_TOKEN_BACKSLASH; else if (c == '[') return SWIG_TOKEN_LBRACKET; else if (c == ']') return SWIG_TOKEN_RBRACKET; else if (c == '@') return SWIG_TOKEN_AT; else if (c == '$') return SWIG_TOKEN_DOLLAR; else if (c == '#') return SWIG_TOKEN_POUND; /* Look for multi-character sequences */ else if (c == '/') state = 1; /* Comment (maybe) */ else if (c == '\"') { state = 2; /* Possibly a string */ s->string_start = s->line; } else if (c == ':') state = 5; /* maybe double colon */ else if (c == '0') state = 83; /* An octal or hex value */ else if (c == '\'') { s->string_start = s->line; state = 9; /* A character constant */ } else if (c == '`') { s->string_start = s->line; state = 900; } else if (c == '.') state = 100; /* Maybe a number, maybe just a period */ else if (isdigit(c)) state = 8; /* A numerical value */ else state = 99; /* An error */ break; case 1: /* Comment block */ if ((c = nextchar(s)) == 0) return(0); if (c == '/') { state = 10; /* C++ style comment */ Clear(s->text); Setline(s->text, Getline(s->str)); Setfile(s->text, Getfile(s->str)); Append(s->text," "); } else if (c == '*') { state = 11; /* C style comment */ Clear(s->text); Setline(s->text, Getline(s->str)); Setfile(s->text, Getfile(s->str)); Append(s->text," "); } else { retract(s,1); return SWIG_TOKEN_SLASH; } break; case 10: /* C++ style comment */ if ((c = nextchar(s)) == 0) { /* add_error(0,"Unterminated comment",comment_start); */ return 0; } if (c == '\n') { return SWIG_TOKEN_ENDLINE; } else { state = 10; } break; case 11: /* C style comment block */ if ((c = nextchar(s)) == 0) { /* add_error(0,"Unterminated comment",comment_start); */ return 0; } if (c == '*') { state = 12; } else { state = 11; } break; case 12: /* Still in C style comment */ if ((c = nextchar(s)) == 0) { /* add_error(0,"Unterminated comment",comment_start); */ return 0; } if (c == '*') { state = 12; } else if (c == '/') { Clear(s->text); state = 0; } else { state = 11; } break; case 2: /* Processing a string */ if ((c = nextchar(s)) == 0) { /* add_error(0,"Unterminated string", string_start); */ return 0; } if (c == '\"') { return SWIG_TOKEN_STRING; } else if (c == '\\') { state = 21; /* Possibly an escape sequence. */ break; } else state = 2; break; case 21: /* An escape sequence. get next character, then go back to processing strings */ if ((c = nextchar(s)) == 0) return 0; state = 2; break; case 3: /* Maybe a not equals */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_LNOT; else if (c == '=') return SWIG_TOKEN_NOTEQUAL; else { retract(s,1); return SWIG_TOKEN_LNOT; } break; case 31: /* AND or Logical AND */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_AND; else if (c == '&') return SWIG_TOKEN_LAND; else { retract(s,1); return SWIG_TOKEN_AND; } break; case 32: /* OR or Logical OR */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_OR; else if (c == '|') return SWIG_TOKEN_LOR; else { retract(s,1); return SWIG_TOKEN_OR; } break; case 33: /* EQUAL or EQUALTO */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_EQUAL; else if (c == '=') return SWIG_TOKEN_EQUALTO; else { retract(s,1); return SWIG_TOKEN_EQUAL; } break; case 4: /* A wrapper generator directive (maybe) */ if (( c= nextchar(s)) == 0) return SWIG_TOKEN_PERCENT; if (c == '{') { state = 40; /* Include block */ Clear(s->text); Setline(s->text, Getline(s->str)); Setfile(s->text, Getfile(s->str)); s->start_line = s->line; } else if (strchr(s->idstart,'%') && ((isalpha(c)) || (c == '_'))) state = 7; else { retract(s,1); return SWIG_TOKEN_PERCENT; } break; case 40: /* Process an include block */ if ((c = nextchar(s)) == 0) { /* add_error(0,"Unterminated code block.", start_line); */ return 0; } if (c == '%') state = 41; break; case 41: /* Still processing include block */ if ((c = nextchar(s)) == 0) { /* add_error(0,"Unterminated code block.", start_line); */ return 0; } if (c == '}') { Delitem(s->text,DOH_END); Delitem(s->text,DOH_END); return SWIG_TOKEN_CODEBLOCK; } else { state = 40; } break; case 5: /* Maybe a double colon */ if (( c = nextchar(s)) == 0) return SWIG_TOKEN_COLON; if ( c == ':') return SWIG_TOKEN_DCOLON; else { retract(s,1); return SWIG_TOKEN_COLON; } break; case 60: /* shift operators */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_LESSTHAN; if (c == '<') return SWIG_TOKEN_LSHIFT; else if (c == '=') return SWIG_TOKEN_LTEQUAL; else { retract(s,1); return SWIG_TOKEN_LESSTHAN; } break; case 61: if ((c = nextchar(s)) == 0) return SWIG_TOKEN_GREATERTHAN; if (c == '>') return SWIG_TOKEN_RSHIFT; else if (c == '=') return SWIG_TOKEN_GTEQUAL; else { retract(s,1); return SWIG_TOKEN_GREATERTHAN; } break; case 7: /* Identifier */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_ID; if (isalnum(c) || (c == '_') || (c == '$')) { state = 7; } else { retract(s,1); return SWIG_TOKEN_ID; } break; case 8: /* A numerical digit */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_INT; if (c == '.') {state = 81;} else if ((c == 'e') || (c == 'E')) {state = 86;} else if ((c == 'f') || (c == 'F')) { Delitem(s->text,DOH_END); return SWIG_TOKEN_FLOAT; } else if (isdigit(c)) { state = 8;} else if ((c == 'l') || (c == 'L')) { state = 87; } else if ((c == 'u') || (c == 'U')) { state = 88; } else { retract(s,1); return SWIG_TOKEN_INT; } break; case 81: /* A floating pointer number of some sort */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_DOUBLE; if (isdigit(c)) state = 81; else if ((c == 'e') || (c == 'E')) state = 82; else if ((c == 'f') || (c == 'F') || (c == 'l') || (c == 'L')) { Delitem(s->text,DOH_END); return SWIG_TOKEN_FLOAT; } else { retract(s,1); return(SWIG_TOKEN_DOUBLE); } break; case 82: if ((c = nextchar(s)) == 0) { retract(s,1); return SWIG_TOKEN_INT; } if ((isdigit(c)) || (c == '-') || (c == '+')) state = 86; else { retract(s,2); return(SWIG_TOKEN_INT); } break; case 83: /* Might be a hexidecimal or octal number */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_INT; if (isdigit(c)) state = 84; else if ((c == 'x') || (c == 'X')) state = 85; else if (c == '.') state = 81; else if ((c == 'l') || (c == 'L')) { state = 87; } else if ((c == 'u') || (c == 'U')) { state = 88; } else { retract(s,1); return SWIG_TOKEN_INT; } break; case 84: /* This is an octal number */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_INT; if (isdigit(c)) state = 84; else if ((c == 'l') || (c == 'L')) { state = 87; } else if ((c == 'u') || (c == 'U')) { state = 88; } else { retract(s,1); return SWIG_TOKEN_INT; } break; case 85: /* This is an hex number */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_INT; if ((isdigit(c)) || (c=='a') || (c=='b') || (c=='c') || (c=='d') || (c=='e') || (c=='f') || (c=='A') || (c=='B') || (c=='C') || (c=='D') || (c=='E') || (c=='F')) state = 85; else if ((c == 'l') || (c == 'L')) { state = 87; } else if ((c == 'u') || (c == 'U')) { state = 88; } else { retract(s,1); return SWIG_TOKEN_INT; } break; case 86: /* Rest of floating point number */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_DOUBLE; if (isdigit(c)) state = 86; else if ((c == 'f') || (c == 'F')) { Delitem(s->text,DOH_END); return SWIG_TOKEN_FLOAT; } else if ((c == 'l') || (c == 'L')) { Delitem(s->text,DOH_END); return SWIG_TOKEN_DOUBLE; } else { retract(s,1); return SWIG_TOKEN_DOUBLE; } break; case 87 : /* A long integer of some sort */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_LONG; if ((c == 'u') || (c == 'U')) { return SWIG_TOKEN_ULONG; } else if ((c == 'l') || (c == 'L')) { state = 870; } else { retract(s,1); return SWIG_TOKEN_LONG; } break; /* A long long integer */ case 870: if ((c = nextchar(s)) == 0) return SWIG_TOKEN_LONGLONG; if ((c == 'u') || (c == 'U')) { return SWIG_TOKEN_ULONGLONG; } else { retract(s,1); return SWIG_TOKEN_LONGLONG; } /* An unsigned number */ case 88: if ((c = nextchar(s)) == 0) return SWIG_TOKEN_UINT; if ((c == 'l') || (c == 'L')) { state = 880; } else { retract(s,1); return SWIG_TOKEN_UINT; } break; /* Possibly an unsigned long long or unsigned long */ case 880: if ((c = nextchar(s)) == 0) return SWIG_TOKEN_ULONG; if ((c == 'l') || (c == 'L')) return SWIG_TOKEN_ULONGLONG; else { retract(s,1); return SWIG_TOKEN_ULONG; } /* A character constant */ case 9: if ((c = nextchar(s)) == 0) { /* add_error(0,"Unterminated character constant", string_start); */ return 0; } if (c == '\'') { return(SWIG_TOKEN_CHAR); } else if (c == '\\') state = 91; break; case 91: if ((c = nextchar(s)) == 0) { /* add_error(0,"Unterminated character constant", string_start); */ return 0; } state = 9; break; /* A period or maybe a floating point number */ case 100: if ((c = nextchar(s)) == 0) return (0); if (isdigit(c)) state = 81; else { retract(s,1); return SWIG_TOKEN_PERIOD; } break; /* An illegal character */ /* Reverse string */ case 900: if ((c = nextchar(s)) == 0) { /* add_error(0,"Unterminated character constant", string_start); */ return 0; } if (c == '`') { return(SWIG_TOKEN_RSTRING); } break; default: return SWIG_TOKEN_ILLEGAL; } } }
void Turret::serverProcess (DWORD time) { Parent::serverProcess(time); if (data->isSustained == false) { if (!getControlClient() && getState () == StaticBase::Enabled && isActive()) { targetsTracked = 0; Player *closePlayer = chooseTarget (); if (targetsTracked) sleepTime = manager->getCurrentTime() + 3.0; if (closePlayer) { if (state == EXTENDED) trackAndFire (closePlayer, 0.032); else extend (0.032); } else if (!targetsTracked && manager->getCurrentTime() > sleepTime) { if (state != RETRACTED) { retract (0.032); } } } if (!getControlClient()) updateMove (NULL, 0.032); else updateSkip++; } else { switch (m_fireState) { case Waiting: { serverProcessWaiting(time); } break; case Firing: { serverProcessFiring(time); } break; case Reloading: { serverProcessReloading(time); } break; default: AssertFatal(0, "invalid state"); } if (m_fireState == Firing) { float e = getEnergy(); e -= data->energyRate * 0.032; if(e < 0.0) { unshoot(); e = 0.0; } setEnergy(e); } } }
void Turret::updateMove (PlayerMove *move, float interval) { if (data->isSustained == false) { if (getControlClient() && state != EXTENDED) { if (!isGhost()) extend (interval); } if (state != EXTENDED) move = NULL; float oTR = turretRotation; float oTE = turretElevation; if (move && (!animThread || animThread->getPriority() != -1 || animThread->getPosition() >= 1.0)) { #if 0 float maxSpeed = data->speed * data->speedModifier * interval; float moveFrac = interval * 32; #else float maxSpeed = data->speed * data->speedModifier; float moveFrac = interval * 16; #endif float pitch = m_clamp(move->pitch,-maxSpeed,maxSpeed); float turn = m_clamp(move->turnRot,-maxSpeed,maxSpeed); turretElevation += pitch * moveFrac; turretRotation += turn * moveFrac; wrapElevation (); if (maxElevation != minElevation) { if (turretElevation > maxElevation) turretElevation = maxElevation; if (turretElevation < minElevation) turretElevation = minElevation; } wrapRotation (); if (maxRotation != minRotation) { if (turretRotation > maxRotation) turretRotation = maxRotation; if (turretRotation < minRotation) turretRotation = minRotation; } if (move->trigger) { if (!isGhost ()) shoot (true); } if (move->jumpAction && !isGhost()) { const char *fn = scriptName("jump"); if(fn) Console->executef(2, fn, scriptThis()); } } if (elevationThread && maxElevation != minElevation) elevationThread->SetPosition ((turretElevation - minElevation) / (maxElevation - minElevation)); if (rotationThread) { if (!isEqual (maxRotation, minRotation)) rotationThread->SetPosition ((turretRotation - minRotation) / (maxRotation - minRotation)); else rotationThread->SetPosition (turretRotation / M_2PI); } // this is for the firing anim... if (animThread && state == EXTENDED) animThread->AdvanceTime (interval); // this is for the power anim... if (animThread && isGhost()) { if (state == EXTENDING) extend (interval); else if (state == RETRACTING) retract (interval); } if (!isGhost ()) { // Need to animate on the server to get the // node transforms. image.shape->animate (); if (oTE != turretElevation) setMaskBits (ElevationMask); if (oTR != turretRotation) setMaskBits (TRotationMask); } } else { if (getControlClient() && state != EXTENDED) { if (!isGhost()) extend (interval); } if (state != EXTENDED) move = NULL; float oTR = turretRotation; float oTE = turretElevation; if (move && (!animThread || animThread->getPriority() != -1 || animThread->getPosition() >= 1.0)) { float maxSpeed = data->speed * interval; float pitch = m_clamp(move->pitch,-maxSpeed,maxSpeed); float turn = m_clamp(move->turnRot,-maxSpeed,maxSpeed); float moveFrac = interval * 32; turretElevation += pitch * moveFrac; turretRotation += turn * moveFrac; wrapElevation (); if (maxElevation != minElevation) { if (turretElevation > maxElevation) turretElevation = maxElevation; if (turretElevation < minElevation) turretElevation = minElevation; } wrapRotation (); if (maxRotation != minRotation) { if (turretRotation > maxRotation) turretRotation = maxRotation; if (turretRotation < minRotation) turretRotation = minRotation; } if (move->trigger && m_fireState == Waiting) { if (!isGhost ()) shoot(true, NULL); } else if (!move->trigger && m_fireState == Firing) { if (!isGhost()) unshoot(); } if (move->jumpAction && !isGhost()) { if (m_fireState == Firing) unshoot(); const char *fn = scriptName("jump"); if(fn) Console->executef(2, fn, scriptThis()); } } if (elevationThread && maxElevation != minElevation) elevationThread->SetPosition ((turretElevation - minElevation) / (maxElevation - minElevation)); if (rotationThread) { if (!isEqual (maxRotation, minRotation)) rotationThread->SetPosition ((turretRotation - minRotation) / (maxRotation - minRotation)); else rotationThread->SetPosition (turretRotation / M_2PI); } // this is for the firing anim... if (animThread && state == EXTENDED) animThread->AdvanceTime (interval); // this is for the power anim... if (animThread && isGhost()) { if (state == EXTENDING) extend (interval); else if (state == RETRACTING) retract (interval); } if (!isGhost ()) { // Need to animate on the server to get the // node transforms. image.shape->animate (); if (oTE != turretElevation) setMaskBits (ElevationMask); if (oTR != turretRotation) setMaskBits (TRotationMask); } } }
static int look(Scanner * s) { int state; int c = 0; state = 0; Clear(s->text); s->start_line = s->line; Setfile(s->text, Getfile(s->str)); while (1) { switch (state) { case 0: if ((c = nextchar(s)) == 0) return (0); /* Process delimiters */ if (c == '\n') { return SWIG_TOKEN_ENDLINE; } else if (!isspace(c)) { retract(s, 1); state = 1000; Clear(s->text); Setline(s->text, s->line); Setfile(s->text, Getfile(s->str)); } break; case 1000: if ((c = nextchar(s)) == 0) return (0); if (c == '%') state = 4; /* Possibly a SWIG directive */ /* Look for possible identifiers */ else if ((isalpha(c)) || (c == '_') || (s->idstart && strchr(s->idstart, c))) state = 7; /* Look for single character symbols */ else if (c == '(') return SWIG_TOKEN_LPAREN; else if (c == ')') return SWIG_TOKEN_RPAREN; else if (c == ';') return SWIG_TOKEN_SEMI; else if (c == ',') return SWIG_TOKEN_COMMA; else if (c == '*') state = 220; else if (c == '}') return SWIG_TOKEN_RBRACE; else if (c == '{') return SWIG_TOKEN_LBRACE; else if (c == '=') state = 33; else if (c == '+') state = 200; else if (c == '-') state = 210; else if (c == '&') state = 31; else if (c == '|') state = 32; else if (c == '^') state = 230; else if (c == '<') state = 60; else if (c == '>') state = 61; else if (c == '~') return SWIG_TOKEN_NOT; else if (c == '!') state = 3; else if (c == '\\') return SWIG_TOKEN_BACKSLASH; else if (c == '[') return SWIG_TOKEN_LBRACKET; else if (c == ']') return SWIG_TOKEN_RBRACKET; else if (c == '@') return SWIG_TOKEN_AT; else if (c == '$') state = 75; else if (c == '#') return SWIG_TOKEN_POUND; else if (c == '?') return SWIG_TOKEN_QUESTION; /* Look for multi-character sequences */ else if (c == '/') { state = 1; /* Comment (maybe) */ s->start_line = s->line; } else if (c == '\"') { state = 2; /* Possibly a string */ s->start_line = s->line; Clear(s->text); } else if (c == ':') state = 5; /* maybe double colon */ else if (c == '0') state = 83; /* An octal or hex value */ else if (c == '\'') { s->start_line = s->line; Clear(s->text); state = 9; /* A character constant */ } else if (c == '`') { s->start_line = s->line; Clear(s->text); state = 900; } else if (c == '.') state = 100; /* Maybe a number, maybe just a period */ else if (isdigit(c)) state = 8; /* A numerical value */ else state = 99; /* An error */ break; case 1: /* Comment block */ if ((c = nextchar(s)) == 0) return (0); if (c == '/') { state = 10; /* C++ style comment */ Clear(s->text); Setline(s->text, Getline(s->str)); Setfile(s->text, Getfile(s->str)); Append(s->text, "//"); } else if (c == '*') { state = 11; /* C style comment */ Clear(s->text); Setline(s->text, Getline(s->str)); Setfile(s->text, Getfile(s->str)); Append(s->text, "/*"); } else if (c == '=') { return SWIG_TOKEN_DIVEQUAL; } else { retract(s, 1); return SWIG_TOKEN_SLASH; } break; case 10: /* C++ style comment */ if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated comment\n"); return SWIG_TOKEN_ERROR; } if (c == '\n') { retract(s,1); return SWIG_TOKEN_COMMENT; } else { state = 10; } break; case 11: /* C style comment block */ if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated comment\n"); return SWIG_TOKEN_ERROR; } if (c == '*') { state = 12; } else { state = 11; } break; case 12: /* Still in C style comment */ if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated comment\n"); return SWIG_TOKEN_ERROR; } if (c == '*') { state = 12; } else if (c == '/') { return SWIG_TOKEN_COMMENT; } else { state = 11; } break; case 2: /* Processing a string */ if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated string\n"); return SWIG_TOKEN_ERROR; } if (c == '\"') { Delitem(s->text, DOH_END); return SWIG_TOKEN_STRING; } else if (c == '\\') { Delitem(s->text, DOH_END); get_escape(s); } else state = 2; break; case 3: /* Maybe a not equals */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_LNOT; else if (c == '=') return SWIG_TOKEN_NOTEQUAL; else { retract(s, 1); return SWIG_TOKEN_LNOT; } break; case 31: /* AND or Logical AND or ANDEQUAL */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_AND; else if (c == '&') return SWIG_TOKEN_LAND; else if (c == '=') return SWIG_TOKEN_ANDEQUAL; else { retract(s, 1); return SWIG_TOKEN_AND; } break; case 32: /* OR or Logical OR */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_OR; else if (c == '|') return SWIG_TOKEN_LOR; else if (c == '=') return SWIG_TOKEN_OREQUAL; else { retract(s, 1); return SWIG_TOKEN_OR; } break; case 33: /* EQUAL or EQUALTO */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_EQUAL; else if (c == '=') return SWIG_TOKEN_EQUALTO; else { retract(s, 1); return SWIG_TOKEN_EQUAL; } break; case 4: /* A wrapper generator directive (maybe) */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_PERCENT; if (c == '{') { state = 40; /* Include block */ Clear(s->text); Setline(s->text, Getline(s->str)); Setfile(s->text, Getfile(s->str)); s->start_line = s->line; } else if (s->idstart && strchr(s->idstart, '%') && ((isalpha(c)) || (c == '_'))) { state = 7; } else if (c == '=') { return SWIG_TOKEN_MODEQUAL; } else { retract(s, 1); return SWIG_TOKEN_PERCENT; } break; case 40: /* Process an include block */ if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated block\n"); return SWIG_TOKEN_ERROR; } if (c == '%') state = 41; break; case 41: /* Still processing include block */ if ((c = nextchar(s)) == 0) { set_error(s,s->start_line,"Unterminated code block"); return 0; } if (c == '}') { Delitem(s->text, DOH_END); Delitem(s->text, DOH_END); Seek(s->text,0,SEEK_SET); return SWIG_TOKEN_CODEBLOCK; } else { state = 40; } break; case 5: /* Maybe a double colon */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_COLON; if (c == ':') state = 50; else { retract(s, 1); return SWIG_TOKEN_COLON; } break; case 50: /* DCOLON, DCOLONSTAR */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_DCOLON; else if (c == '*') return SWIG_TOKEN_DCOLONSTAR; else { retract(s, 1); return SWIG_TOKEN_DCOLON; } break; case 60: /* shift operators */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_LESSTHAN; if (c == '<') state = 240; else if (c == '=') return SWIG_TOKEN_LTEQUAL; else { retract(s, 1); return SWIG_TOKEN_LESSTHAN; } break; case 61: if ((c = nextchar(s)) == 0) return SWIG_TOKEN_GREATERTHAN; if (c == '>') state = 250; else if (c == '=') return SWIG_TOKEN_GTEQUAL; else { retract(s, 1); return SWIG_TOKEN_GREATERTHAN; } break; case 7: /* Identifier */ if ((c = nextchar(s)) == 0) state = 71; else if (isalnum(c) || (c == '_') || (c == '$')) { state = 7; } else { retract(s, 1); state = 71; } break; case 71: /* Identifier or true/false */ if (cparse_cplusplus) { if (Strcmp(s->text, "true") == 0) return SWIG_TOKEN_BOOL; else if (Strcmp(s->text, "false") == 0) return SWIG_TOKEN_BOOL; } return SWIG_TOKEN_ID; break; case 75: /* Special identifier $ */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_DOLLAR; if (isalnum(c) || (c == '_') || (c == '*') || (c == '&')) { state = 7; } else { retract(s,1); if (Len(s->text) == 1) return SWIG_TOKEN_DOLLAR; state = 71; } break; case 8: /* A numerical digit */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_INT; if (c == '.') { state = 81; } else if ((c == 'e') || (c == 'E')) { state = 82; } else if ((c == 'f') || (c == 'F')) { Delitem(s->text, DOH_END); return SWIG_TOKEN_FLOAT; } else if (isdigit(c)) { state = 8; } else if ((c == 'l') || (c == 'L')) { state = 87; } else if ((c == 'u') || (c == 'U')) { state = 88; } else { retract(s, 1); return SWIG_TOKEN_INT; } break; case 81: /* A floating pointer number of some sort */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_DOUBLE; if (isdigit(c)) state = 81; else if ((c == 'e') || (c == 'E')) state = 820; else if ((c == 'f') || (c == 'F')) { Delitem(s->text, DOH_END); return SWIG_TOKEN_FLOAT; } else if ((c == 'l') || (c == 'L')) { Delitem(s->text, DOH_END); return SWIG_TOKEN_DOUBLE; } else { retract(s, 1); return (SWIG_TOKEN_DOUBLE); } break; case 82: if ((c = nextchar(s)) == 0) { retract(s, 1); return SWIG_TOKEN_INT; } if ((isdigit(c)) || (c == '-') || (c == '+')) state = 86; else { retract(s, 2); return (SWIG_TOKEN_INT); } break; case 820: /* Like case 82, but we've seen a decimal point. */ if ((c = nextchar(s)) == 0) { retract(s, 1); return SWIG_TOKEN_DOUBLE; } if ((isdigit(c)) || (c == '-') || (c == '+')) state = 86; else { retract(s, 2); return (SWIG_TOKEN_DOUBLE); } break; case 83: /* Might be a hexadecimal or octal number */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_INT; if (isdigit(c)) state = 84; else if ((c == 'x') || (c == 'X')) state = 85; else if (c == '.') state = 81; else if ((c == 'l') || (c == 'L')) { state = 87; } else if ((c == 'u') || (c == 'U')) { state = 88; } else { retract(s, 1); return SWIG_TOKEN_INT; } break; case 84: /* This is an octal number */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_INT; if (isdigit(c)) state = 84; else if ((c == 'l') || (c == 'L')) { state = 87; } else if ((c == 'u') || (c == 'U')) { state = 88; } else { retract(s, 1); return SWIG_TOKEN_INT; } break; case 85: /* This is an hex number */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_INT; if (isxdigit(c)) state = 85; else if ((c == 'l') || (c == 'L')) { state = 87; } else if ((c == 'u') || (c == 'U')) { state = 88; } else { retract(s, 1); return SWIG_TOKEN_INT; } break; case 86: /* Rest of floating point number */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_DOUBLE; if (isdigit(c)) state = 86; else if ((c == 'f') || (c == 'F')) { Delitem(s->text, DOH_END); return SWIG_TOKEN_FLOAT; } else if ((c == 'l') || (c == 'L')) { Delitem(s->text, DOH_END); return SWIG_TOKEN_DOUBLE; } else { retract(s, 1); return SWIG_TOKEN_DOUBLE; } break; case 87: /* A long integer of some sort */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_LONG; if ((c == 'u') || (c == 'U')) { return SWIG_TOKEN_ULONG; } else if ((c == 'l') || (c == 'L')) { state = 870; } else { retract(s, 1); return SWIG_TOKEN_LONG; } break; /* A long long integer */ case 870: if ((c = nextchar(s)) == 0) return SWIG_TOKEN_LONGLONG; if ((c == 'u') || (c == 'U')) { return SWIG_TOKEN_ULONGLONG; } else { retract(s, 1); return SWIG_TOKEN_LONGLONG; } /* An unsigned number */ case 88: if ((c = nextchar(s)) == 0) return SWIG_TOKEN_UINT; if ((c == 'l') || (c == 'L')) { state = 880; } else { retract(s, 1); return SWIG_TOKEN_UINT; } break; /* Possibly an unsigned long long or unsigned long */ case 880: if ((c = nextchar(s)) == 0) return SWIG_TOKEN_ULONG; if ((c == 'l') || (c == 'L')) return SWIG_TOKEN_ULONGLONG; else { retract(s, 1); return SWIG_TOKEN_ULONG; } /* A character constant */ case 9: if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated character constant\n"); return SWIG_TOKEN_ERROR; } if (c == '\'') { Delitem(s->text, DOH_END); return (SWIG_TOKEN_CHAR); } else if (c == '\\') { Delitem(s->text, DOH_END); get_escape(s); } break; /* A period or maybe a floating point number */ case 100: if ((c = nextchar(s)) == 0) return (0); if (isdigit(c)) state = 81; else { retract(s, 1); return SWIG_TOKEN_PERIOD; } break; case 200: /* PLUS, PLUSPLUS, PLUSEQUAL */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_PLUS; else if (c == '+') return SWIG_TOKEN_PLUSPLUS; else if (c == '=') return SWIG_TOKEN_PLUSEQUAL; else { retract(s, 1); return SWIG_TOKEN_PLUS; } break; case 210: /* MINUS, MINUSMINUS, MINUSEQUAL, ARROW */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_MINUS; else if (c == '-') return SWIG_TOKEN_MINUSMINUS; else if (c == '=') return SWIG_TOKEN_MINUSEQUAL; else if (c == '>') state = 211; else { retract(s, 1); return SWIG_TOKEN_MINUS; } break; case 211: /* ARROW, ARROWSTAR */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_ARROW; else if (c == '*') return SWIG_TOKEN_ARROWSTAR; else { retract(s, 1); return SWIG_TOKEN_ARROW; } break; case 220: /* STAR, TIMESEQUAL */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_STAR; else if (c == '=') return SWIG_TOKEN_TIMESEQUAL; else { retract(s, 1); return SWIG_TOKEN_STAR; } break; case 230: /* XOR, XOREQUAL */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_XOR; else if (c == '=') return SWIG_TOKEN_XOREQUAL; else { retract(s, 1); return SWIG_TOKEN_XOR; } break; case 240: /* LSHIFT, LSEQUAL */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_LSHIFT; else if (c == '=') return SWIG_TOKEN_LSEQUAL; else { retract(s, 1); return SWIG_TOKEN_LSHIFT; } break; case 250: /* RSHIFT, RSEQUAL */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_RSHIFT; else if (c == '=') return SWIG_TOKEN_RSEQUAL; else { retract(s, 1); return SWIG_TOKEN_RSHIFT; } break; /* An illegal character */ /* Reverse string */ case 900: if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated character constant\n"); return SWIG_TOKEN_ERROR; } if (c == '`') { Delitem(s->text, DOH_END); return (SWIG_TOKEN_RSTRING); } break; default: return SWIG_TOKEN_ILLEGAL; } } }
// 悔棋:无须传入参数: 传出参数 : p1 现在位置的棋子, p2=0 下棋模式,p2!=0 之前位置的棋子 void board::back(int& p1,int& p2) { if (m_before[0].empty()){ //cout << "error:: 无棋可悔" << endl; return; } p1=(m_before[0].top()), p2=(m_before[1].top()); m_before[0].pop(); m_before[1].pop(); if (m_before[0].empty()) pre_chess = -1; else pre_chess = m_before[0].top(); // 局面改变 who_step--; selected_color = (selected_color + 1) % 2; int cx(0), cy(0); data_itoxy(p1, cx, cy); m_chess_pos = m_curr_color[cx][cy]; if (m_chess_pos % 2!=selected_color) { //cout << "back error; 颜色不一样???" << endl; return; } m_curr_color[cx][cy] = 0; if (!retract(selected_color, cx, cy)) { //cout << "back error ::不能移棋???" << endl; return; } // p2!=0 表示移棋的模式 if (p2) { int bx(0), by(0); data_itoxy(p2, bx, by); lay(selected_color, bx, by); m_curr_color[bx][by] = m_chess_pos; m_chess[m_chess_pos] = p2; // m_chess_num--; } else { if (m_chess_pos != m_chess_num) { //cout << "error:: 删除的棋子不是最后下的棋子??" << endl; } m_chess_num--; int b_x(0), b_y(0); data_itoxy(m_chess[m_chess_pos], b_x, b_y); //cout << "错误:在(" << b_x << ',' << b_y << ")处success" <<endl; } }