L
Little
Could someone tell me what I am doing wrong here about declaring
mutiple double linked lists. This is what the information is for the
project and the code wil be below that. Thank your soo much for your
assitance in helping me solve this problem.
Information:
Create 4 double linked lists as follows:
(a) A double linked list called NAMES which will contain all C like
identifiers of less than
256 characters long identified in the input file F. Each identifier
will be represented by
a triple (I, length, string) where I is used to identify the type of
the object as being an
identifier, length is an integer representing the length of the
identifier in characters, and
string is a string of characters representing the identifier itself.
(b) A double linked list called NUMBERS which will contain all C like
numbers of less than
256 characters long identified in the input file F. Each number will be
represented by a
triple (N, length, string) where N is used to identify the type of the
objects as being a
number, length is an integer representing the length of the number in
characters, and
string is the string of characters representing the number itself.
(c) A double linked list called SEPARATORS which will contain all C
language separators
and operators identified in the input file F. Each separator will be
represented by a triple
(X, length, string) where X is S for separators, O for operators, R for
symbols denoting
relations, L for new line and E for end of file. The length is an
integer representing the
length of the symbol and string is the string of characters
representing the symbol itself.
(d) A double linked list called UNKNOWN which will contain all symbols
you discovered in
the file F which could not be classi ed in the lists NAMES, NUMBERS,
SEPARATORS.
Each object in this list will be represented by a triple (Y, length,
string) where Y is used
to signify that an unknown symbol was discovered, length is an integer
representing the
length in characters of the unknown symbol, and string is the string of
characters that
make up the unknown symbol itself.
The input file F will be an arbitrary text file in your directory. The
actions of list creation and list printing will be programmed as
functions which will be called from a main program. Use in your program
the functions list(H, T), to create an empty list L whose header is H
and tail is T, and append(L, OBJ), to append the object OBJ to the list
L.
The start of the code:
#include <stdio.h>
#include <stdlib.h>
#include "scan.h"
struct Names
{
char* TYPE;
int length;
char data[256];
struct Names* next;
struct Names* prev;
};
typdef struct Names DLList;
typdef struct Names header;
struct Numbers
{
char* TYPE;
int length;
char data[256];
struct Names* next;
struct Names* prev;
};
typdef struct Numbers DLList;
typdef struct Numbers header;
struct Separators
{
char* TYPE;
int length;
char data[256];
struct Names* next;
struct Names* prev;
};
typdef struct Separators DLList;
typdef struct Separators header;
struct Uknown
{
char* TYPE;
int length;
char data[256];
struct Names* next;
struct Names* prev;
};
typdef struct Uknown DLList;
typdef struct Uknown header;
typdef struct header *headerpt;
header *list(header *h,header *t)
{
h->prev=null;
h->next=t;
h->DLList=null;
t->prev=h;
t->next=null;
t->DLList=null;
return(h);
}
void append(header *l, DLList *obj)
{
DLList *q=l->next;
while(q->next != null)
q=q->next;
obj->prev=q->prev;
obj->next=q;
q->prev=obj;
q=obj->prev;
q->next=obj;
}
int main (int argc, char *argv[])
{
extern TKN get_token(FILE *);
TKN Token;
FILE *Input;
int Done = 0, k;
Input = fopen(argv[1], "r");
while (!Done)
{
Token = get_token( Input );
switch (Token.Code)
{
case 'I':
{
/* process identifier */
break;
}
case 'N':
{
/* process integer number */
break;
}
case 'F':
{
/* process real number */
break;
}
case 'W':
{
break;
}
case 'L':
{
break;
}
case 'U':
{
if (Token.String[0] == 'Z')
Done = 1;
break;
}
case 'O':
{
break;
}
case 'E':
{
break;
}
}
} /* end while */
return 0;
}
Again thank you.
mutiple double linked lists. This is what the information is for the
project and the code wil be below that. Thank your soo much for your
assitance in helping me solve this problem.
Information:
Create 4 double linked lists as follows:
(a) A double linked list called NAMES which will contain all C like
identifiers of less than
256 characters long identified in the input file F. Each identifier
will be represented by
a triple (I, length, string) where I is used to identify the type of
the object as being an
identifier, length is an integer representing the length of the
identifier in characters, and
string is a string of characters representing the identifier itself.
(b) A double linked list called NUMBERS which will contain all C like
numbers of less than
256 characters long identified in the input file F. Each number will be
represented by a
triple (N, length, string) where N is used to identify the type of the
objects as being a
number, length is an integer representing the length of the number in
characters, and
string is the string of characters representing the number itself.
(c) A double linked list called SEPARATORS which will contain all C
language separators
and operators identified in the input file F. Each separator will be
represented by a triple
(X, length, string) where X is S for separators, O for operators, R for
symbols denoting
relations, L for new line and E for end of file. The length is an
integer representing the
length of the symbol and string is the string of characters
representing the symbol itself.
(d) A double linked list called UNKNOWN which will contain all symbols
you discovered in
the file F which could not be classi ed in the lists NAMES, NUMBERS,
SEPARATORS.
Each object in this list will be represented by a triple (Y, length,
string) where Y is used
to signify that an unknown symbol was discovered, length is an integer
representing the
length in characters of the unknown symbol, and string is the string of
characters that
make up the unknown symbol itself.
The input file F will be an arbitrary text file in your directory. The
actions of list creation and list printing will be programmed as
functions which will be called from a main program. Use in your program
the functions list(H, T), to create an empty list L whose header is H
and tail is T, and append(L, OBJ), to append the object OBJ to the list
L.
The start of the code:
#include <stdio.h>
#include <stdlib.h>
#include "scan.h"
struct Names
{
char* TYPE;
int length;
char data[256];
struct Names* next;
struct Names* prev;
};
typdef struct Names DLList;
typdef struct Names header;
struct Numbers
{
char* TYPE;
int length;
char data[256];
struct Names* next;
struct Names* prev;
};
typdef struct Numbers DLList;
typdef struct Numbers header;
struct Separators
{
char* TYPE;
int length;
char data[256];
struct Names* next;
struct Names* prev;
};
typdef struct Separators DLList;
typdef struct Separators header;
struct Uknown
{
char* TYPE;
int length;
char data[256];
struct Names* next;
struct Names* prev;
};
typdef struct Uknown DLList;
typdef struct Uknown header;
typdef struct header *headerpt;
header *list(header *h,header *t)
{
h->prev=null;
h->next=t;
h->DLList=null;
t->prev=h;
t->next=null;
t->DLList=null;
return(h);
}
void append(header *l, DLList *obj)
{
DLList *q=l->next;
while(q->next != null)
q=q->next;
obj->prev=q->prev;
obj->next=q;
q->prev=obj;
q=obj->prev;
q->next=obj;
}
int main (int argc, char *argv[])
{
extern TKN get_token(FILE *);
TKN Token;
FILE *Input;
int Done = 0, k;
Input = fopen(argv[1], "r");
while (!Done)
{
Token = get_token( Input );
switch (Token.Code)
{
case 'I':
{
/* process identifier */
break;
}
case 'N':
{
/* process integer number */
break;
}
case 'F':
{
/* process real number */
break;
}
case 'W':
{
break;
}
case 'L':
{
break;
}
case 'U':
{
if (Token.String[0] == 'Z')
Done = 1;
break;
}
case 'O':
{
break;
}
case 'E':
{
break;
}
}
} /* end while */
return 0;
}
Again thank you.