Main Page   Data Structures   File List   Data Fields   Globals  

token.c

Go to the documentation of this file.
00001 /*
00002  * InCode - [ token.c ]
00003  * (c) 2002, J. Weeks
00004  * jweeks@mailandnews.com
00005  *
00006  * This is the inCode tokenizer engine.  Given an input stream (from the input modules)
00007  * it will break it up into tokens, which will then be sent to the compiler.
00008  *
00009  * I haven't yet decided wether to implement optimization into this section or not.
00010  *   - optomization else where would probably require another stream of tokens, thus
00011  *     more memory overhead
00012  *   - optomization else where could be more easily turn on/off with a compiler
00013  *     flag.
00014  */
00015 
00016 /***************************************************************************
00017  *                                                                         *
00018  *   This program is free software; you can redistribute it and/or modify  *
00019  *   it under the terms of the GNU General Public License as published by  *
00020  *   the Free Software Foundation; either version 2 of the License, or     *
00021  *   (at your option) any later version.                                   *
00022  *                                                                         *
00023  ***************************************************************************/
00024 
00025 #include <stdio.h>
00026 #include <stdlib.h>
00027 
00028 #include "token.h"
00029 #include "input.h"
00030 
00031 Token token;
00032 
00038 int tokenInit(void) {
00039   token.next = NULL;
00040   token.type = 0;
00041   return 0;
00042 }
00043 
00050 int tokenClose(void) {
00051   // deallocate any memory used
00052   return 0;
00053 }
00054 
00055 int tokenize(void) {
00056   Token *curTok;
00057   printf("\n+ tokenize()\n");
00058   while(tokenGet(curTok) == 0) {
00059     printf("Token (%c)\n", curTok->name[0]);
00060     if(curTok->name[0] == 'Q') break;
00061     tokenDelete(curTok);
00062   }
00063   printf("- tokenize()\n");
00064   return 0;
00065 }
00066 
00067 int tokenGet(Token *tok) {
00068   char c;
00069 
00070   //printf("+ getToken()\n");
00071   tokenNew(tok);
00072   if(inputChar(&c)) {
00073     tok->name[0] = c;
00074     tok->name[1] = '\n';
00075     //tok->type = isWhat(c);
00076   } else return 1;
00077   printf("- getToken()\n");
00078   return 0;
00079 }
00080 
00081 int tokenNew(Token *newTok) {
00082   newTok = malloc(sizeof(Token));
00083   return 0;
00084 }
00085 
00086 int tokenDelete(Token *delTok) {
00087   printf("+ delTok()\n");
00088   free(&delTok);
00089   printf("- delTok()\n");
00090   return 0;
00091 }
00092 
00093 //tokenAdd(

Generated on Thu Feb 14 09:15:11 2002 for InCode by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001