#include "lemon-conf.h" #include #include #include #include static char *where = NULL; static int first_time = 1; void lexer_init(char *starts) { where = starts; } int lexer_token(char **token, int *token_type) { char *next; if(first_time) { next = where; first_time = 0; } else { next = NULL; } next = strtok(next," \t\n"); if(next == NULL) return 0; char *newtoken = strdup(next); if(strcmp(newtoken,"stanza") == 0) { *token_type = STANZA; } else if(strcmp(newtoken,"{") == 0) { *token_type = LBRACE; } else if(strcmp(newtoken,"}") == 0) { *token_type = RBRACE; } else if(strcmp(newtoken,";") == 0) { *token_type = SEMICOLON; } else if(strcmp(newtoken,"=") == 0) { *token_type = EQUAL; } else // must be IDENTIFIER, NUMBER, OR STRING { if( (*newtoken == '"') && (*(newtoken+strlen(newtoken)-1) == '"') ) { *token_type = STRING; } else if(isdigit(*newtoken)) { int i; for(i=0;i