Output: (21, if) (10, 'x') (18, :)=9 (101001001) (s) (11032)...
To how the two digit recognition output binary behind later in parentheses: for example (11, 0329 (101001001))
Source code for the following
#include
#include
#include
# define _KEY_WORD_END "waiting for expanding"
Typedef struct
{
Int typenum;
Char * word;
} WORD;
Char input [255].
Char token [255]="";
Int p_input;
Int p_token;
char ch;
Char * rwtab []={" begin "and" if ", "then", and "while" and "do" and "end", _KEY_WORD_END};
The WORD * scaner ();
Int main ()
{
Int over=1;
The WORD * oneword=new WORD;
Printf (" Enter your words; (end with #) : ");
The scanf (" % [^ #] s ", input);
P_input=0;
Printf (" Your words: \ n \ n % s ", input);
While (over & lt; 1000 & amp; & The over!=1) {
Oneword=scaner ();
If (oneword - & gt; Typenum & lt; 1000)
Printf (") (% d, % s \ n ", oneword - & gt; Typenum oneword - & gt; The word);
Over=oneword - & gt; Typenum;
}
Printf (" \ npress # to exit: ");
The scanf (" % [^ #] s ", input);
return 0;
}
Char m_getch () {
Ch=input [p_input];
P_input=p_input + 1;
Return (ch);
}
Void getbc () {
While (ch=='| | ch==10)
{
Ch=input [p_input];
P_input + +;
}
}
Void concat () {
Token [p_token]=ch;
P_token + +;
Token [p_token]='\ 0';
}
Int letter ()
{
If ((ch & gt;='a' & amp; & Ch & lt;='z') | | (ch & gt;='A' & amp; & Ch & lt;='Z'))
return 1;
The else
return 0;
}
Int digit ()
{
If (ch & gt;='0' & amp; & Ch & lt;='9') return 1;
The else return 0;
}
Int reserve ()
{
Int I=0;
While (STRCMP (rwtab [I], _KEY_WORD_END))
{
if(! STRCMP (rwtab [I], token))
Return the I + 1;
i++;
}
Return 10;
}
Void retract ()
{
P_input -;
}
Char * DTB ()
{
return NULL;
}
The WORD * scaner ()
{
WORD * myword=new WORD;
Myword - & gt; Typenum=10;
Myword - & gt; The word="";
P_token=0;
M_getch ();
Getbc ();
If (letter ())
{
While (letter () | | digit ())
{
Concat ();
M_getch ();
}
Retract ();
Myword - & gt; Typenum=reserve ();
Myword - & gt; The word=token;
Return (myword);
}
Else if (digit ())
{
While (digit ())
{
Concat ();
M_getch ();
}
Retract ();
Myword - & gt; Typenum=11;
Myword - & gt; The word=token;
Return (myword);
}
The else switch (ch)
{
Case: '=' m_getch ();
If (ch=='=')
{
Myword - & gt; Typenum=25;
Myword - & gt; The word==="";
Return (myword);
}
Retract ();
Myword - & gt; Typenum=21;
Myword - & gt; The word="=";
Return (myword);
break;
Case: '+'
Myword - & gt; Typenum=13;
Myword - & gt; The word="+";
Return (myword);
break;
In case the '-' :
Myword - & gt; Typenum=14;
Myword - & gt; The word="-";
Return (myword);
break;
Case: '*'
Myword - & gt; Typenum=15;
Myword - & gt; The word="*";
Return (myword);
break;
Case '/' :
Myword - & gt; Typenum=16;
Myword - & gt; The word="/"
Return (myword);
break;
Case '('
Myword - & gt; Typenum=27;
Myword - & gt; Word="(";
Return (myword);
break;
Case ') :
Myword - & gt; Typenum=28;
Myword - & gt; The word=") ";
Return (myword);
break;
Case [' : '
Myword - & gt; Typenum=28;
Myword - & gt; Word="["
Return (myword);
break;
Case '] ':
Myword - & gt; Typenum=29;
Myword - & gt; The word="] ";
Return (myword);
break;
Case '{' :
Myword - & gt; Typenum=30;
Myword - & gt; The word="{";
Return (myword);
break;
Case '} ':
Myword - & gt; Typenum=31;
Myword - & gt; The word="} ";
Return (myword);
break;
Case ', ':'
Myword - & gt; Typenum=32;
Myword - & gt; The word=", ";
Return (myword);
break;
Case: ':' m_getch ();
If (ch=='=')
{
Myword - & gt; Typenum=18;
Myword - & gt; The word=":=";
Return (myword);
}
Retract ();
Myword - & gt; Typenum=17;
Myword - & gt; The word=":";
Return (myword);
break;
Case '; ':
Myword - & gt; Typenum=26;
Myword - & gt; The word="; ";
Return (myword);
break;
Case '& gt; ': m_getch ();
If (ch=='=')
{
Myword - & gt; Typenum=24;
Myword - & gt; The word="& gt;=";
Return (myword);
}
Retract ();
Myword - & gt; Typenum=23;
Myword - & gt; The word="& gt;";
Return (myword);
break;
Case '& lt; ': m_getch ();
If (ch=='=')
{
Myword - & gt; Typenum=22;
Myword - & gt; The word="& lt;=";
Return (myword);
}
Else if (ch=='& gt; ')
{
Myword - & gt; Typenum=21;
Myword - & gt; The word="& lt; & gt; ";
Return (myword);
}
Retract ();
Myword - & gt; Typenum=20.
Myword - & gt; The word="& lt;";
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull