int dAssemblerLexical::NextToken () { static short transitionsCount[] = { 2, 0, 0}; static short transitionsStart[] = { 0, 2, 2}; static short nextStateSet[] = { 1, 2}; static char nextCharacterSet[] = { 46, 93}; m_startIndex = m_index; int state = 0; int zeroCount = 2; char ch = NextChar(); do { int transCount = transitionsCount[state]; int tranStart = transitionsStart[state]; int nextStateIndex = GetNextStateIndex (ch, transCount, &nextCharacterSet[tranStart]); if (nextStateIndex >= 0) { ch = NextChar(); short* const stateArray = &nextStateSet[tranStart]; state = stateArray[nextStateIndex]; } else { UnGetChar (); switch (state) { case 1: { GetLexString (); {return '.';} state = 0; ch = NextChar(); break; } case 2: { GetLexString (); {return ']';} state = 0; ch = NextChar(); break; } default: { // Lexical error return -1; } } } if (!ch) { zeroCount--; } } while (zeroCount); // Unknown pattern return -1; }
SetFileName(register char term) {register int c; register int i=0; while ((int)(c=GetChar()) != EOF && c!='\n' && c!=term) symb[i++]=c; symb[i]= 0; if (c!=term) Error("Non-closed file name:%s",symb); if (c=='\n') UnGetChar(c); yylval.Num= c; yychar= ((int)c==EOF? E_O_F: yylex()); }
GetNum(int *p) /*read integer number in decimal format */ {int v=0; while (GetChar() != EOF) { if (isdigit(f_char)) v=v*10+(f_char-'0'); else { UnGetChar(f_char); break; }; }; return (*p=v); }
GetOctalNum(int *p) /*read integer number in octal format */ {int v=0; while (GetChar() != EOF) { if (isdigit(f_char)) v=(v<<3)+(f_char-'0'); else { UnGetChar(f_char); break; }; }; return (*p=v); }
bool TLexer::IsEndToken(char c) { switch (c) { case '\n': { return true; } case '\t': { return true; } case ' ': { return true; } case ')': { UnGetChar(); return true; } case '(': { UnGetChar(); return true; } default: { return false; } } }
GetHexNum(int *p) /*read integer number in hexadecimal format */ {int v=0; while (GetChar() != EOF) { if (isdigit(f_char)) v=(v<<4)+(f_char-'0'); else if (f_char>='a' && f_char<='f') v=(v<<4)+(f_char-'a'+10); else if (f_char>='A' && f_char<='F') v=(v<<4)+(f_char-'A'+10); else { UnGetChar(f_char); break; }; }; return (*p=v); }
void CommHandler(void) //UART4 Interrupt handler implementation { int c = GetChar(); if (c >= 0) { LEDon(); switch (c) { /* case 'a': debugAutoPan ^= 1; print("Autopan messages %s\r\n", debugAutoPan ? "on" : "off"); break; case 'b': print("rebooting into boot loader ...\r\n"); Delay_ms(1000); bootloader(); break; case 'c': debugCnt ^= 1; print("counter messages %s\r\n", debugCnt ? "on" : "off"); break; case 'd': debugPrint ^= 1; print("debug messages %s\r\n", debugPrint ? "on" : "off"); break; case 'g': Delay_ms(100); PutChar('x'); for (int i = 0; i < CONFIGDATASIZE; i++) { uint8_t data = configData[i]; PutChar(data); //print("\\%c\\",(char)data); } break; case 'G': printConfig(); break; #if 0 case 'H': if (CharAvailable() >= CONFIGDATASIZE) { for (int i = 0; i < CONFIGDATASIZE; i++) { uint8_t data = GetChar(); if (data <= LARGEST_CONFIGDATA) { configData[i] = data; } } configSave(); } else { UnGetChar(c); // try again in next loop } break; #endif case 'h': for (int i = 0; i < CONFIGDATASIZE; i++) { int data; while ((data = GetChar()) < 0) ; if (data <= LARGEST_CONFIGDATA) { configData[i] = data; } } configSave(); break; case 'i': ConfigMode = 1; break; case 'j': ConfigMode = 0; break; case 'o': debugOrient ^= 1; print("Orientation messages %s\r\n", debugOrient ? "on" : "off"); break; case 'p': debugPerf ^= 1; print("performance messages %s\r\n", debugPerf ? "on" : "off"); break; case 'r': debugRC ^= 1; print("RC messages %s\r\n", debugRC ? "on" : "off"); break; case 'R': print("rebooting...\r\n"); Delay_ms(1000); reboot(); break; case 's': debugSense ^= 1; print("Sensor messages %s\r\n", debugSense ? "on" : "off"); break; case 'u': { extern int bDeviceState; printUSART("\r\nYY bDeviceState %3d VCPConnectMode %d\r\n", bDeviceState, GetVCPConnectMode()); break; } case 'v': print("Version: %s\r\n", __EV_VERSION); break; case '+': testPhase += 0.1; print("test phase output %5.1f\r\n", testPhase); break; case '-': testPhase -= 0.1; print("test phase output %5.1f\r\n", testPhase); break; case '~': { debugLAKITU ^= 1; print("Angle messages %s\r\n", debugLAKITU ? "on" : "off"); } break; case '`':{ LAKITU_enable ^= 1; print("Turning LAKITU control %s\r\n", LAKITU_enable ? "on" : "off"); } break; */ case '$': { if (CharAvailable() >= LAKITU_LENGTH){ float tmp1 =0.0f, tmp2=0.0f, tmp3= 0.0f; for (int i = 0; i < LAKITU_LENGTH; i++){ float tmp_val = (float)(((int)GetChar())-ASCII2INT); if(i<3){ if(i==0){ tmp1 += tmp_val*100.0; }else if(i==1){ tmp1 += tmp_val*10.0; }else{ tmp1 += tmp_val*1.0; } }else if(i>2 && i<6){ if(i==3){ tmp2 += tmp_val*100.0; }else if(i==4){ tmp2 += tmp_val*10.0; }else{ tmp2 += tmp_val*1.0; } }else if(i>5 && i<9){ if(i==6){ tmp3 += tmp_val*100.0; }else if(i==7){ tmp3 += tmp_val*10.0; }else{ tmp3 += tmp_val*1.0; } }else if(i==9 && (int)tmp_val == 11){//handle last character if ((tmp1 >= 30.0) && (tmp1 <= 140.0)){ LakituAngles[PITCH] = tmp1; } if ((tmp2 >= 0.0) && (tmp2 <= 180.0)){ LakituAngles[ROLL] = tmp2; } if ((tmp3 >= 0.0) && (tmp3 <= 360.0)){ LakituAngles[YAW] = tmp3; } } } //print("%f,%f,%f,%f,%f,%f\n",tmp1,tmp2,tmp3,LakituAngles[PITCH],LakituAngles[ROLL],LakituAngles[YAW]); } else { UnGetChar(c); // try again in next loop } } break; /* case '?': print("CLI documentation\r\n"); // print("\t'+' test phase output increase (now %5.1f)\r\n", testPhase); //print("\t'-' test phase output decrease (now %5.1f)\r\n", testPhase); print("\t'a' autopan messages display (now %s)\r\n", debugAutoPan ? "on" : "off"); print("\t'b' reboot into bootloader\r\n"); print("\t'c' counter messages display (now %s)\r\n", debugCnt ? "on" : "off"); print("\t'd' debug messages display (now %s)\r\n", debugPrint ? "on" : "off"); print("\t'g' dump configuration (binary)\r\n"); print("\t'G' dump configuration (hexadecimal)\r\n"); // print("\t'h' write and save config array\r\n"); print("\t'i' enter config mode (now %s)\r\n", ConfigMode ? "on" : "off"); print("\t'j' leave config mode (now %s)\r\n", ConfigMode ? "on" : "off"); print("\t'o' orientation messages display (now %s)\r\n", debugOrient ? "on" : "off"); print("\t'p' performance messages display (now %s)\r\n", debugPerf ? "on" : "off"); print("\t'r' RC messages display (now %s)\r\n", debugRC ? "on" : "off"); print("\t'R' reboot\r\n"); print("\t's' toggle sensor messages display (now %s)\r\n", debugSense ? "on" : "off"); print("\t'u' print USB state (bDeviceState %3d VCPConnectMode %d)\r\n", bDeviceState, GetVCPConnectMode()); print("\t'v' print version (%s)\r\n", __EV_VERSION); break; */ default: // TODO break; } } }
void CommHandler(void) //UART4 Interrupt handler implementation { int c = GetChar(); if (c >= 0) { LEDon(); switch (c) { case 'a': debugAutoPan ^= 1; print("Autopan messages %s\r\n", debugAutoPan ? "on" : "off"); break; case 'b': print("rebooting into boot loader ...\r\n"); Delay_ms(1000); bootloader(); break; case 'c': debugCnt ^= 1; print("counter messages %s\r\n", debugCnt ? "on" : "off"); break; case 'd': debugPrint ^= 1; print("debug messages %s\r\n", debugPrint ? "on" : "off"); break; case 'g': Delay_ms(100); PutChar('x'); for (int i = 0; i < CONFIGDATASIZE; i++) { uint8_t data = configData[i]; PutChar(data); } break; case 'G': printConfig(); break; #if 0 case 'H': if (CharAvailable() >= CONFIGDATASIZE) { for (int i = 0; i < CONFIGDATASIZE; i++) { uint8_t data = GetChar(); if (data <= LARGEST_CONFIGDATA) { configData[i] = data; } } configSave(); } else { UnGetChar(c); // try again in next loop } break; #endif case 'h': for (int i = 0; i < CONFIGDATASIZE; i++) { int data; while ((data = GetChar()) < 0) ; if (data <= LARGEST_CONFIGDATA) { configData[i] = data; } } configSave(); break; case 'i': ConfigMode = 1; break; case 'j': ConfigMode = 0; break; case 'o': debugOrient ^= 1; print("Orientation messages %s\r\n", debugOrient ? "on" : "off"); break; case 'O': debugGravityVector ^= 1; print("GVector messages %s\r\n", debugGravityVector ? "on" : "off"); break; case 'S': debugSetpoints ^= 1; print("Setpoints messages %s\r\n", debugSetpoints ? "on" : "off"); break; case 'p': debugPerf ^= 1; print("performance messages %s\r\n", debugPerf ? "on" : "off"); break; case 'r': debugRC ^= 1; print("RC messages %s\r\n", debugRC ? "on" : "off"); break; case 'R': print("rebooting...\r\n"); Delay_ms(1000); reboot(); break; case 's': debugSense ^= 1; print("Sensor messages %s\r\n", debugSense ? "on" : "off"); break; case 'u': { extern int bDeviceState; printUSART("\r\nYY bDeviceState %3d VCPConnectMode %d\r\n", bDeviceState, GetVCPConnectMode()); break; } case 'v': print("Version: %s\r\n", __EV_VERSION); break; case '+': testPhase += 0.1; print("test phase output %5.1f\r\n", testPhase); break; case '-': testPhase -= 0.1; print("test phase output %5.1f\r\n", testPhase); break; /* case '?': print("CLI documentation\r\n"); // print("\t'+' test phase output increase (now %5.1f)\r\n", testPhase); //print("\t'-' test phase output decrease (now %5.1f)\r\n", testPhase); print("\t'a' autopan messages display (now %s)\r\n", debugAutoPan ? "on" : "off"); print("\t'b' reboot into bootloader\r\n"); print("\t'c' counter messages display (now %s)\r\n", debugCnt ? "on" : "off"); print("\t'd' debug messages display (now %s)\r\n", debugPrint ? "on" : "off"); print("\t'g' dump configuration (binary)\r\n"); print("\t'G' dump configuration (hexadecimal)\r\n"); // print("\t'h' write and save config array\r\n"); print("\t'i' enter config mode (now %s)\r\n", ConfigMode ? "on" : "off"); print("\t'j' leave config mode (now %s)\r\n", ConfigMode ? "on" : "off"); print("\t'o' orientation messages display (now %s)\r\n", debugOrient ? "on" : "off"); print("\t'p' performance messages display (now %s)\r\n", debugPerf ? "on" : "off"); print("\t'r' RC messages display (now %s)\r\n", debugRC ? "on" : "off"); print("\t'R' reboot\r\n"); print("\t's' toggle sensor messages display (now %s)\r\n", debugSense ? "on" : "off"); print("\t'u' print USB state (bDeviceState %3d VCPConnectMode %d)\r\n", bDeviceState, GetVCPConnectMode()); print("\t'v' print version (%s)\r\n", __EV_VERSION); break; */ default: // TODO break; } } }
extern int StyleLex( Bool fSymbol) { int c , len; int token; char *s; Bool fFloat; dbgmsg(">StyleLex"); retry: while ( isspace( c = GetChar(StyleFile) ) ) { if ( c == '\n' ) { c = ' '; StylecLine ++; } } if ( c == '#' ) { while ( ( c = GetChar(StyleFile) ) != '\n' ); StylecLine ++; goto retry; } if ( c == '"' ) { s = StyleComSymbol; len = 0; while ( ( c = GetChar(StyleFile) ) != '"' ) { if ( c == '\\' ) { c = GetChar(StyleFile); } *s = c; if ( len < SIZE_SYMBOL ) { s ++; len ++; } } *s = 0; token = T_SCONST; } else if ( isalpha(c) ) { s = StyleComSymbol; len = 0; do { *s = c; if ( len < SIZE_SYMBOL ) { s ++; len ++; } c = GetChar(StyleFile); } while ( ( isalpha(c) ) || ( isdigit(c) ) || ( c == '.' ) || ( c == '_' ) ); *s = 0; UnGetChar(StyleFile,c); if ( fSymbol ) { token = T_SYMBOL; } else { token = CheckReserved(StyleComSymbol); } } else if ( isdigit(c) ) { s = StyleComSymbol; len = 0; fFloat = FALSE; do { *s = c; if ( c == '.' ) { if ( fFloat ) { printf(". duplicate\n"); } fFloat = TRUE; } if ( len < SIZE_SYMBOL ) { s ++; len ++; } c = GetChar(StyleFile); } while ( ( isdigit(c) ) || ( c == '.' ) ); *s = 0; UnGetChar(StyleFile,c); if ( fFloat ) { StyleComInt = (int)(atof(StyleComSymbol) * 65535.0); } else { StyleComInt = atoi(StyleComSymbol); } token = T_ICONST; } else { switch (c) { case EOF: token = T_EOF; break; default: token = c; break; } } dbgmsg("<StyleLex"); return (token); }
yylex() /*****************Lexical analizer routine******************/ {int t,i; int c; symbol *s; lex: SkipBlanks(); if (!compfl && c != '#') { /*Ignore this line */ ignline: if ((int)c == EOF) return E_O_F; if (!GetString(symb,sizeof(symb))) { Error("Unclosed conditional bracket at EOF"); return E_O_F; }; #if BUFFERED f_char= ' '; /*any char. diff. from the '\n' */ #endif c= '\n'; }; if (c == '#' && !compfl) { SkipBlanks(); if (c=='i' || c=='I') goto ignline; UnGetChar(c); c= '#'; compfl= -1; }; if (c=='%') goto ignline; /* %comment line */ if (c=='/') { if ((c=GetChar())=='*') { /*Comment */ comm: while ((int)(c=GetChar()) != EOF && c != '*'); if ((int)c==EOF) return E_O_F; while ((c=GetChar()) == '*'); if (c != '/') goto comm; goto lex; /*get the next symbol */ }; UnGetChar(c); c= '/'; }; if (c=='\'') { yylval.Num= GetChar(); if ((c=GetChar()) != '\'') Error("' expected"); return NUM; }; if (isdigit(c)) { /*Number */ if (c=='0') { c= GetChar(); if (c=='x' || c=='X') { /*0xHEXALNUMBER */ GetHexNum(&yylval.Num); return NUM; }; if (isdigit(c)) { /*Octal number */ UnGetChar(c); GetOctalNum(&yylval.Num); return NUM; }; }; UnGetChar(c); if (!isdigit(c)) yylval.Num= 0; else GetNum(&yylval.Num); return NUM; }; if (c=='_' || isalpha(c)) { /*Identifier */ register symbol *blk= blkptr; i= 0; while (c=='_' || isalnum(c)) { symb[i++]= c; c= GetChar(); }; UnGetChar(c); symb[i++]= 0; do { s= LookUp(symb,blk); if (!blk) break; blk= blk->Block; } while (!s); if (!s) { s= Insert(symb,SYM,0); if (!s) { Error("Symbol table is overflowed, symbol:%s",symb); return E_O_F; }; s->Block= blkptr; }; idnptr= s; yylval.Sym= s; if (s->Type == NUM) return SYM; /********** yylval.Num= s->Val; return NUM; }; **********/ return s->Type; }; if ((int)c == EOF) return E_O_F; t= (int)c; if (c=='=' || c=='<' || c=='>') { i= GetChar(); if (c==i) t= (c=='<'? SHL: c=='>'? SHR: EQ); else UnGetChar(i); }; yylval.Num= t; /*Delimiter */ return t; }
int dParserLexical::NextToken () { static short transitionsCount[] = { 74, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 126, 126, 10, 0, 0, 63, 63, 0, 0, 2, 127, 127, 127, 127, 77, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 127, 127, 127, 127, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; static short transitionsStart[] = { 0, 74, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 204, 78, 78, 214, 214, 78, 78, 277, 279, 406, 279, 279, 533, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 645, 772, 645, 645, 899, 900, 901, 902, 903, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925}; static short nextStateSet[] = { 1, 1, 1, 1, 79, 52, 47, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 41, 42, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 45, 46, 1, 1, 1, 1, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 48, 39, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 49, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 37, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 60, 59, 58, 57, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 56, 55, 54, 53, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 2, 106, 103, 100, 96, 92, 88, 84, 80, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 81, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 10, 82, 82, 85, 86, 87, 9, 89, 90, 91, 8, 93, 94, 95, 7, 97, 98, 99, 6, 101, 102, 5, 104, 105, 4, 107, 108, 109, 110, 3}; static char nextCharacterSet[] = { 9, 10, 13, 32, 37, 39, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 95, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 9, 10, 13, 32, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 95, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 42, 47, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 33, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 37, 101, 108, 112, 114, 115, 116, 117, 123, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 110, 105, 111, 110, 111, 107, 101, 110, 116, 97, 114, 116, 105, 103, 104, 116, 114, 101, 99, 101, 102, 116, 120, 112, 101, 99, 116}; m_startIndex = m_index; int state = 0; int zeroCount = 2; char ch = NextChar(); do { int transCount = transitionsCount[state]; int tranStart = transitionsStart[state]; int nextStateIndex = GetNextStateIndex (ch, transCount, &nextCharacterSet[tranStart]); if (nextStateIndex >= 0) { ch = NextChar(); short* const stateArray = &nextStateSet[tranStart]; state = stateArray[nextStateIndex]; } else { UnGetChar (); switch (state) { case 1: { GetLexString (); {} state = 0; ch = NextChar(); break; } case 2: { GetLexString (); { return dParserCompiler::GRAMMAR_SEGMENT;} state = 0; ch = NextChar(); break; } case 3: { GetLexString (); { return dParserCompiler::EXPECT;} state = 0; ch = NextChar(); break; } case 4: { GetLexString (); { return dParserCompiler::LEFT;} state = 0; ch = NextChar(); break; } case 5: { GetLexString (); { return dParserCompiler::PREC;} state = 0; ch = NextChar(); break; } case 6: { GetLexString (); { return dParserCompiler::RIGHT;} state = 0; ch = NextChar(); break; } case 7: { GetLexString (); { return dParserCompiler::START;} state = 0; ch = NextChar(); break; } case 8: { GetLexString (); { return dParserCompiler::TOKEN;} state = 0; ch = NextChar(); break; } case 9: { GetLexString (); { return dParserCompiler::UNION;} state = 0; ch = NextChar(); break; } case 10: { GetLexString (); { m_tokenString.Replace(0, 2, ""); m_tokenString.Replace(m_tokenString.Size() - 2, 2, ""); return dParserCompiler::CODE_BLOCK;} state = 0; ch = NextChar(); break; } case 11: { GetLexString (); { m_tokenString = "!"; return('!'); } state = 0; ch = NextChar(); break; } case 12: { GetLexString (); { m_tokenString = "%"; return('%'); } state = 0; ch = NextChar(); break; } case 13: { GetLexString (); { m_tokenString = "&"; return('&'); } state = 0; ch = NextChar(); break; } case 14: { GetLexString (); { m_tokenString = "("; return('('); } state = 0; ch = NextChar(); break; } case 15: { GetLexString (); { m_tokenString = ")"; return(')'); } state = 0; ch = NextChar(); break; } case 16: { GetLexString (); { m_tokenString = "*"; return('*'); } state = 0; ch = NextChar(); break; } case 17: { GetLexString (); { m_tokenString = "+"; return('+'); } state = 0; ch = NextChar(); break; } case 18: { GetLexString (); { m_tokenString = ","; return(','); } state = 0; ch = NextChar(); break; } case 19: { GetLexString (); { m_tokenString = "-"; return('-'); } state = 0; ch = NextChar(); break; } case 20: { GetLexString (); { m_tokenString = "."; return('.'); } state = 0; ch = NextChar(); break; } case 21: { GetLexString (); { m_tokenString = "/"; return('/'); } state = 0; ch = NextChar(); break; } case 22: { GetLexString (); { m_tokenString = ":"; return(':'); } state = 0; ch = NextChar(); break; } case 23: { GetLexString (); { m_tokenString = ";"; return(';'); } state = 0; ch = NextChar(); break; } case 24: { GetLexString (); { m_tokenString = "<"; return('<'); } state = 0; ch = NextChar(); break; } case 25: { GetLexString (); { m_tokenString = "="; return('='); } state = 0; ch = NextChar(); break; } case 26: { GetLexString (); { m_tokenString = ">"; return('>'); } state = 0; ch = NextChar(); break; } case 27: { GetLexString (); { m_tokenString = "?"; return('?'); } state = 0; ch = NextChar(); break; } case 28: { GetLexString (); { m_tokenString = m_tokenString.SubString (1, 1); return(m_tokenString[0]); } state = 0; ch = NextChar(); break; } case 29: { GetLexString (); { m_tokenString = "["; return('['); } state = 0; ch = NextChar(); break; } case 30: { GetLexString (); { m_tokenString = "\\"; return('\\'); } state = 0; ch = NextChar(); break; } case 31: { GetLexString (); { m_tokenString = "]"; return(']'); } state = 0; ch = NextChar(); break; } case 32: { GetLexString (); { m_tokenString = "^"; return('^'); } state = 0; ch = NextChar(); break; } case 33: { GetLexString (); { m_tokenString = "{"; return('{'); } state = 0; ch = NextChar(); break; } case 34: { GetLexString (); { m_tokenString = "|"; return('|'); } state = 0; ch = NextChar(); break; } case 35: { GetLexString (); { m_tokenString = "}"; return('}'); } state = 0; ch = NextChar(); break; } case 36: { GetLexString (); { m_tokenString = "~"; return('~'); } state = 0; ch = NextChar(); break; } case 37: { GetLexString (); {} state = 0; ch = NextChar(); break; } case 38: { GetLexString (); {} state = 0; ch = NextChar(); break; } case 39: { GetLexString (); {} state = 0; ch = NextChar(); break; } case 40: { GetLexString (); { return dParserCompiler::INTEGER;} state = 0; ch = NextChar(); break; } case 41: { GetLexString (); { return(dParserCompiler::COLOM); } state = 0; ch = NextChar(); break; } case 42: { GetLexString (); { return(dParserCompiler::SIMICOLOM); } state = 0; ch = NextChar(); break; } case 43: { GetLexString (); { return dParserCompiler::LITERAL;} state = 0; ch = NextChar(); break; } case 44: { GetLexString (); { return dParserCompiler::LITERAL;} state = 0; ch = NextChar(); break; } case 45: { GetLexString (); { ReadBalancedExpresion ('{', '}'); return dParserCompiler::SEMANTIC_ACTION;} state = 0; ch = NextChar(); break; } case 46: { GetLexString (); { return(dParserCompiler::OR); } state = 0; ch = NextChar(); break; } default: { // Lexical error return -1; } } } if (!ch) { zeroCount--; } } while (zeroCount); // Unknown pattern return -1; }
void CommHandler(void) //UART4 Interrupt handler implementation { int c = GetChar(); if (c >= 0) { //ConfigMode = 1; LEDon(); //print("got char %02X\r\n", c); switch (c) { case 'b': print("rebooting into boot loader ...\r\n"); Delay_ms(1000); bootloader(); break; case 'c': debugCnt ^= 1; print("counter messages %s\r\n", debugCnt ? "on" : "off"); break; case 'd': debugPrint ^= 1; print("debug messages %s\r\n", debugPrint ? "on" : "off"); break; case 'g': Delay_ms(100); PutChar('x'); for (int i = 0; i < CONFIGDATASIZE; i++) { uint8_t data = configData[i]; PutChar(data); } break; case 'G': printConfig(); break; #if 0 case 'H': if (CharAvailable() >= CONFIGDATASIZE) { for (int i = 0; i < CONFIGDATASIZE; i++) { uint8_t data = GetChar(); if (data <= LARGEST_CONFIGDATA) { configData[i] = data; } } configSave(); } else { UnGetChar(c); // try again in next loop } break; #endif case 'h': for (int i = 0; i < CONFIGDATASIZE; i++) { int data; while ((data = GetChar()) < 0) ; if (data <= LARGEST_CONFIGDATA) { configData[i] = data; } } configSave(); break; case 'i': ConfigMode = 1; break; case 'j': ConfigMode = 0; break; case 'o': debugOrient ^= 1; print("Orientation messages %s\r\n", debugOrient ? "on" : "off"); break; case 'p': debugPerf ^= 1; print("performance messages %s\r\n", debugPerf ? "on" : "off"); break; case 'r': debugRC ^= 1; print("RC messages %s\r\n", debugRC ? "on" : "off"); break; case 'R': print("rebooting...\r\n"); Delay_ms(1000); reboot(); break; case 's': debugSense ^= 1; print("Sensor messages %s\r\n", debugSense ? "on" : "off"); break; case 'u': { extern int bDeviceState; printUSART("\r\nYY bDeviceState %3d VCPConnectMode %d\r\n", bDeviceState, GetVCPConnectMode()); break; } case '+': testPhase += 0.1; print("test phase output %5.1f\r\n", testPhase); break; case '-': testPhase -= 0.1; print("test phase output %5.1f\r\n", testPhase); break; default: // TODO break; } } }
bool XDMFParser::GetNextAttribute() { char *chr = GetChar(); while (SPACE) chr = GetChar(); if (END_OF_FILE) return false; bool notFound = true; while (notFound) { // // If we hit a closing symbol, then return. // if (CLOSE) { return false; } else if (EMPTY_CLOSE) { UnGetChar(); UnGetChar('<'); return false; } // // If the name doesn't start with a letter, underscore or colon, // it is an error, so skip over the remaining text until reaching // a closing symbol or some white space. // if (!NAME_START) { while (!END_OF_FILE && !SPACE && !CLOSE && !EMPTY_CLOSE) chr = GetChar(); if (CLOSE) { return false; } else if (EMPTY_CLOSE) { UnGetChar('<'); return false; } break; } // // Process the attribute name. // char *cptr = &attributeName[0]; *cptr++ = toupper(*chr); chr = GetChar(); while (NAME_CHAR) { *cptr++ = toupper(*chr); chr = GetChar(); } *cptr = '\0'; // // Skip over white space. // while (SPACE) chr = GetChar(); // // If there isn't an equal sign, it is an error, so skip over the // remaining text until reaching a closing symbol or some white // space. // if (!EQUAL) { while (!END_OF_FILE && !SPACE && !CLOSE && !EMPTY_CLOSE) chr = GetChar(); if (CLOSE) { return false; } else if (EMPTY_CLOSE) { UnGetChar('<'); return false; } break; } // // Skip the equal sign. // chr = GetChar(); // // Skip over white space. // while (SPACE) chr = GetChar(); // // If there isn't a single or double quote, it is an error, so skip // over the remaining text until reaching a closing symbol or some // white space. // if (*chr != '"' && *chr != '\'') { while (!END_OF_FILE && !SPACE && !CLOSE && !EMPTY_CLOSE) chr = GetChar(); if (CLOSE) { return false; } else if (EMPTY_CLOSE) { UnGetChar('<'); return false; } break; } char delimeter = *chr; // // Skip the delimeter. // chr = GetChar(); // // Process the attribute value. // cptr = &attributeValue[0]; while (!END_OF_FILE && *chr != delimeter && !OPEN) { *cptr++ = *chr; chr = GetChar(); } *cptr = '\0'; // // If the closing delimeter is missing, it is an error, so return. // if (OPEN) { UnGetChar(); return false; } notFound = false; } return true; }
XDMFParser::ElementType XDMFParser::GetNextElement() { // // Skip over white space. // char *chr = GetChar(); while (SPACE) chr = GetChar(); if (END_OF_FILE) return TYPE_EOF; if (OPEN) { chr = GetChar(); if (QUESTION) { // // Processing Instructions // chr = GetChar(); while (!END_OF_FILE && (*chr != '?' || *(chr+1) != '>')) chr = GetChar(); chr = GetChar(); chr = GetChar(); return TYPE_PI; } else if (*chr == '!') { chr = GetChar(); if (*(chr) == '-' && *(chr+1) == '-') { // // Comment // chr = GetChar(); chr = GetChar(); while (!END_OF_FILE && (*chr != '-' || *(chr+1) != '-' || *(chr+2) != '>')) chr = GetChar(); chr = GetChar(); chr = GetChar(); chr = GetChar(); return TYPE_COMMENT; } else if (*(chr) == '[' && *(chr+1) == 'C' && *(chr+2) == 'D' && *(chr+3) == 'A' && *(chr+4) == 'T' && *(chr+5) == 'A' && *(chr+6) == '[') { // // We have CData. // chr = GetChar(); chr = GetChar(); chr = GetChar(); chr = GetChar(); chr = GetChar(); chr = GetChar(); chr = GetChar(); // // Skip any leading whitespace. // while (SPACE) chr = GetChar(); cdataOffset = offset + ibuf; int iCdataValue = 0; while (!END_OF_FILE && (*chr != ']' || *(chr+1) != ']' || *(chr+2) != '>')) { chr = GetChar(); if (iCdataValue < 1023) { cdataValue[iCdataValue++] = *chr; } } cdataLength = offset + ibuf - cdataOffset; cdataValue[iCdataValue] = '\0'; chr = GetChar(); chr = GetChar(); chr = GetChar(); return TYPE_CDATA; } else { // // Special elements that start with "<!", such as ATTLIST, // DOCTYPE, and ELEMENT. // while (!END_OF_FILE && *chr != '>') chr = GetChar(); chr = GetChar(); return TYPE_SPECIAL; } } else if (*chr == '/') { // // We have an end tag. // chr = GetChar(); // // If we have a close character, then we have an empty close // tag. This may not be legal, but is required for the parser // to work properly, since these are generated internally when // an open tag is terminated with a "/>". // if (CLOSE) { elementName[0] = '\0'; return TYPE_END_TAG; } // // If it doesn't start with a letter, underscore or colon it // is an error, so skip over the tag looking for the next open // character. // if (!NAME_START) { while (!END_OF_FILE && !OPEN) chr = GetChar(); return TYPE_ERROR; } // // Process the name. // char *cptr = &elementName[0]; *cptr++ = toupper(*chr); chr = GetChar(); while (NAME_CHAR) { *cptr++ = toupper(*chr); chr = GetChar(); } *cptr = '\0'; // // Skip any trailing whitespace after the name. // while (SPACE) chr = GetChar(); // // If the first non-white space character isn't a closing // character, it is an error. // if (!CLOSE) { while (!END_OF_FILE && !OPEN) chr = GetChar(); return TYPE_ERROR; } // // Skip the closing character. // chr = GetChar(); return TYPE_END_TAG; } else { // // We have a start tag. // // // If it doesn't start with a letter, underscore or colon it // is an error, so skip over the tag looking for the next open // character. // if (!NAME_START) { while (!END_OF_FILE && !OPEN) chr = GetChar(); return TYPE_ERROR; } // // Process the name. // char *cptr = &elementName[0]; *cptr++ = toupper(*chr); chr = GetChar(); while (NAME_CHAR) { *cptr++ = toupper(*chr); chr = GetChar(); } *cptr = '\0'; UnGetChar(); return TYPE_START_TAG; } } else { // // We have CData. // // // Skip any leading whitespace. // while (SPACE) chr = GetChar(); if (END_OF_FILE) return TYPE_EOF; cdataOffset = offset + ibuf - 1; int iCdataValue = 0; while (!END_OF_FILE && !OPEN) { if (iCdataValue < 1023) { cdataValue[iCdataValue++] = *chr; } chr = GetChar(); } cdataLength = offset + ibuf - cdataOffset - 1; cdataValue[iCdataValue] = '\0'; UnGetChar(); return TYPE_CDATA; } }