I am making a parser for a CS class, and have yylex returning a token category int for each word I find. So I got flex working. I just have no idea how the .y file translates, and how yyparse uses those values. So I basically have no way of using bison yet.

I don't want anyone to do my homework, I just need this bit; how can I make them communicate?

(For those who don't know what I am talking about and need an intro, lex and yacc, or now flex and bison, are what things like gnu gcc use to make language parsers an compilers. It is suppose to be used widely for compiler and CS language classes, I am hoping that is still the case.)

Here is my lex file. A little messy I know, but it is not the final version:
Code:
%{
#include "ivml.h"
#include <strings.h>
#include "token.h"

struct token *yytokens;                                                  
int yyntokens;                                                           
int yynallocated;                                                        
char *temp;                                                              
int line_num;                                                            

int set_token(int cat);                                                  
void inc_line();                                                         
int pow(int var, int exp);                                               

%}
COMMENT "#".*
IGNORE  {COMMENT}
LETTER  [a-zA-Z]
DIGIT   [0-9]
REALNUM [0-9]*"."[0-9]*
RESERV  "include"
STR     {LETTER}({LETTER}|"."|"/")+
ID      "\t"{LETTER}({LETTER}|{DIGIT}|"_")*
INTEG   [0-9]*

%%

"\n"        { line_num++; }                                              
{IGNORE}
"include"   { set_token(INCLUDE); return INCLUDE; }                      
"default"   { set_token(DEFAULT); return DEFAULT; }                      
"Door"      { set_token(DOOR); return DOOR; }                            
"Room"      { set_token(ROOM); return ROOM; }                            
"Opening"   { set_token(OPENING); return OPENING; }                      
"{"         { set_token(LEFTCURLY); return LEFTCURLY; }                  
"}"         { set_token(RIGHTCURLY); return RIGHTCURLY; }                
"["         { set_token(LEFTSQUARE); return LEFTSQUARE; }                
"]"         { set_token(RIGHTSQUARE); return RIGHTSQUARE; }              
","         { set_token(COMMA); return COMMA; }                          
{ID}        { set_token(IDENT); return IDENT; }                          
{STR}       { set_token(STRING); return STRING; }                        
{REALNUM}   { set_token(REAL); return REAL; }                            
{INTEG}     { set_token(INT); return INT; }                              
.
<<EOF>>     return -1;                                                   

%%

int set_token(int cat)
{
int size = sizeof(cat) + sizeof(yytext) + sizeof(yylex());               
//calculate size to allocate
if(size >= yynallocated)
 {
  //printf("Setting yynallocated from %d ", yynallocated);               
  yynallocated = pow(size, ((yynallocated / 2) + 1 ));                   
  //printf(" to %d\n", yynallocated);                                    
 }

yytokens = malloc(yynallocated);                                         
yytokens[yyntokens].category = cat;                                      
yytokens[yyntokens].linenumber = line_num;                               
temp = yytext;                                                           
yytokens[yyntokens].text = temp;                                         

yylval = yytokens;                                                       

yyntokens++;                                                             

return(cat);                                                             
}

int pow(int var, int exp)
{
if(exp == 0)
 {
  return(1);                                                             
 }

int ret_val = 0;                                                         
while(exp > 0)
 {
  ret_val += var;                                                        
  exp--;                                                                 
 }

return(ret_val);                                                         
}

void inc_line()
{
line_num++;                                                              
}