title: flex and bison:C++ class
body: <p>When I embed a list* pointer into the bison parser, the compiler reports a error that 'list' does not name a type. Here is some necessary pieces; if you need, I can post all code. I am using the latest version of bison and flex. </p>
  
  <pre><code>parser.l
  %{
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  #include "parser.tab.h"
  extern void yyerror(const char *);
  extern int yylex();
  char* outchar;
  char* mychars;
  unsigned int line_number=1;
  %}
  %option nounput 
  %option noyywrap
  %option noinput
  %%
  "automaton"     {return AUTOMATON;}
  "var"       {return VAR;}
  "synclabs"  {return SYNCLABS;}
  "initially"     {return INITIALLY;}
  "loc"       {return LOC;}
  "while"     {return WHILE;}
  "wait"      {return WAIT;}
  "when"      {return WHEN;}
  "do"        {return DO;}
  "sync"      {return SYNC;}
  "goto"      {return GOTO;}
  "end"       {return END;}
  "forbidden"     {return FORBIDDEN;}
  "true"      {return TRUE;}
  "TRUE"      {return TRUE;}
  "false"     {return FALSE;}
  "FALSE"     {return FALSE;}
  
  "="         {return EQ2;}
  "=="        {return EQ;}
  "&gt;="        {return GE;}
  "&lt;="        {return LE;}
  "'"         {return PRIM;}
  ":="        {return ASSIGN;}
  
  ([0-9]+)(("."[0-9]+)?)((([eE])([+-]?)([0-9]+))?)  {yylval.mystring = strdup(yytext);   return INT;}
  
  [-+&lt;&gt;*/&amp;|(){}:;,.=!]|"["|"]" {return *yytext;}
  
  (["$""?"a-zA-Z]|[_])("$"|"?"|[a-zA-Z]|[0-9]|[_]|[~])* { yylval.mystring =   strdup(yytext); return IDENT; }
  
  
  "/*"([^*]|("*"+[^*/]))*"*"+"/" /* skip comment */
  "//".*                         /* skip comment XS*/
  "--".*                         /* skip comment */
  [\n] { ++line_number; 
  
  }
  [ \t\r]                      
  %%
  
  parser.y
  %{
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include&lt;list&gt;
  
  using namespace std;
  
  extern int yylex();
  extern unsigned int line_number;
  void yyerror(const char *msg)
  {       
          printf("Parse error in line %d: ", line_number);
          printf("%s\n", msg);
  }
  Automaton *aut; 
  int var_count=0;
  string *s;
  
  %}
  
  %union{
  char * mystring;
  list* s;
  
  };
  
  
  %token AUTOMATON
  %token VAR
  %token SYNCLABS
  %token INITIALLY
  %token LOC
  %token WHILE
  %token WAIT
  %token WHEN
  %token DO
  %token SYNC
  %token GOTO
  %token END
  %token ASSIGN
  %token FORBIDDEN
  %token TRUE
  %token FALSE
  %token &lt;mystring&gt; INT
  %token &lt;mystring&gt; IDENT
  
  //%nonassoc '(' ')'
  %left  '&amp;'
  %left GE LE EQ EQ2
  %left '+' '-'
  %left '!'
  %left '(' ')'
  %left PRIM
  
  %%  
  
  program:
  commands
  ;
  %%
  
  compile result:
  g++ -O2 -w -c -I .  -g -O2 -o lex.yy.o lex.yy.c
  In file included from parser.l:4:0:
  parser.y:23:2: error： ‘list’does not name a type
  </code></pre>