int GetNum() { register unsigned int v = 0; if (Token("'")) // found « { if (Token("\\")) // Test "\" { v = GetEscCode(); NeedToken("\'"); return v; } v = GetCharNum(); NeedToken("\'"); return v; } if (*FilePtr == '0' && (*(FilePtr+1) =='x' || *(FilePtr+1) == 'X')) { FilePtr+=2; return GetHexNum(16); } return GetDecNum(16); }
long GetNum() { if (Token("0x")) return GetHexNum(); return GetDecNum(); }
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; }