Expert C Programming
jeff_l
(Jeff_L)
#1
time. Sample output is:
% a.out
got char a, at count 1887525
got char b, at count 5979648
got char c, at count 7299030
got char d, at count 9802103
got char e, at count 11060214
got char q, at count 14551814
Programming Solution
cdecl as an FSM
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define MAXTOKENS 100
#define MAXTOKENLEN 64
enum type_tag { IDENTIFIER, QUALIFIER, TYPE };
struct token {
char type;
char string[MAXTOKENLEN];
};
int top = -1;
/ holds all the tokens before first identifier /
struct token stack[MAXTOKENS];
/ holds the token just read /
struct token this;
#define pop stack[top--]
#define push(s) stack[++top]=s
enum type_tag
classify_string(void)