#include
Bool Letter (Char); Bool Digit (Char); Char Keyword [7] [7] = {"Begin", "End", "IF", "" "," while "," do "} CHAR Character; // character variable, store the latest read source character char token [50]; BOOL flags; // character array, stored a string constituting the word symbol
Bool Putchar () {cout << "Do you write the code file in an Analyze.dat file? [Y) / N (N)] ..." << Endl; char Get1; cin >> Get1 ; If (get1 == 'y' || get1 == 'y') {return true;} else {return false;}} // ------------------ ----- Void getBC () {ix (character == '' || {IF (Strlen)! = 0) {for (int K = 0; k <7; K ) {Int a; if (Keyword [k])> Strlen (token) A = Strlen (Keyword [k]); Else A = Strlen (Token); if (! Strncmp (Keyword [K], Token , a)) {cout << "<" << token << ", reserved word>" << endl; flags = false; goto loop;}} if (! Strncmp (" ", Token, 1) || "Strncmp (" - ", token, strlen)) {cout <<" <"<" << ", arithmetic operator>" << endl; Flags = false; goto loop;} else if Strncmp ("<", token, 1) ||! Strncmp ("<=", token, strlen (token) ||! Strncmp ("= <", token, strlen (token) ||! Strncmp (" <>, token, strn (token) ||! Strncmp ("=", token, strlen (token) ||! Strncmp ("> =", token, strlen (token) ||! Strncmp (" > ", token, strlen (token)) {cout <<" <"<< token <<", relational operator> "<< endl; flags = false; goto loop;} else i f (! Strncmp (": =", token, 2)) {cout << "<" << token << ", assignment operator> << endl; flags = false; goto loop;} else if Strncmp (":", token, strlen (token))) {cout << "<" << token << ", colon> << end1; flags = false; goto loop;
} Else if (! ", Strncmp ("; ")) {cout << <" << token << ", semicolon> << endl; flags = false; goto loop;} else IF (! ", strlen (token))) {cout <<" <"<" token << ", right bracket> << endl; flags = false; goto loop;} else ! Strncmp ("(" ("token, strlen))) {cout <<" <"<< token <<", left 括号> << endl; flags = false; goto loop;} else {ix == True) {cout << "<" << token << ", number> << endl; flags = false; goto loop;} else cout << <<<<< token <<", Mogle> << Endl; Flags = false; goto loop;} loop: for (int J = Strlen); J> = 0; J -) token [j] = '/ 0';}} else (TOKEN [STRLEN)] = character; if (strlen) == 1) {flags = true;}} else if (letter) {token [Strlen] = Character Else token [Strlen] = character;} Bool Letter (Char Character1) {IF ((CHAR (97) <= Character1) && (Character1 <= char (122))) || ((CHAR) 65) <= cha RacTer1) && (CHARACTER1 <= char (90)))))) Return True; Else Return False;}
Bool Digit (Char Character1) {IF ((CHAR (48) <= Character1) && (Character1 <= char (57))) Return True; Else Return False;}