-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtokenizer.c
57 lines (42 loc) · 1.11 KB
/
tokenizer.c
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
/*
* tokenizer.c
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
struct TokenizerT_ {
FILE *file;
};
typedef struct TokenizerT_ TokenizerT;
/*
* TKCreate creates a new TokenizerT object for a given token stream
* (given as a string).
*
* TKCreate should copy the arguments so that it is not dependent on
* them staying immutable after returning. (In the future, this may change
* to increase efficiency.)
*
* If the function succeeds, it returns a non-NULL TokenizerT.
* Else it returns NULL.
*/
TokenizerT *TKCreate( FILE *file ) {
TokenizerT *tok = (TokenizerT * ) malloc (sizeof(TokenizerT));
if (tok == NULL) {
return NULL;
}
tok->file = file;
return tok;
}
/*
* TKDestroy destroys a TokenizerT object. It should free all dynamically
* allocated memory that is part of the object being destroyed.
*/
void TKDestroy(TokenizerT * tok) {
free(tok);
}
/*TKGetNextToken returns the next token from the token stream as a character string*/
char *TKGetNextToken( TokenizerT * tk ) {
/*STILL NEED TO MODIFY for this assignment */
return 0;
}