title: Allowing variable length lists in yacc
body: <p>I'd like to be able to parse the following structure:</p>
  
  <pre><code>blah
  {
      "string-1",
      "string-2",
      ...,
      "string-n"
  }
  </code></pre>
  
  <p>I'm using flex to tokenize, and that's working perfectly. I'm using yacc (bison) for the parsing.</p>
  
  <p>What's the recommended way to allow this structure? Right now, in my test.y file, I've got:</p>
  
  <pre><code>blah_command:
      BLAH OPEN_BRACE string_list CLOSE_BRACE
      {
          printf( "String list is %s\n", $3 );
      }
  
  string_list: /* empty */
      |
      STRING
      {
          return $1;
      }
      |
      STRING COMMA string_list
      {
          strcat($1, ",");
          strcat($1, $3);
      }
  </code></pre>
  
  <p>I suspect the strcat() is a really, really bad idea. I'm a real novice when it comes to lex/yacc (about 3 hours experience) so a smack on the wrist and a pointer in the right direction would be great.</p>
  
  <p>EDIT: The goal of this is to allow me to build a test harness for an external application. The lexing/parsing will be used to interpret a test script that the user provides. One command allows the user to send a message to the application, then I read the multi-line response and compare with the variable length list of strings the user has provided in the script. The fragment I've posted above is the way I figured I'd let the user define the possible response.</p>
  
  <p>For example:</p>
  
  <pre><code>blah
  {
      "COMMAND EXECUTED CORRECTLY"
  }
  </code></pre>
  
  <p>or</p>
  
  <pre><code>blah
  {
      "QUERY COMPLETE IN .0034 SECONDS",
      "1 RECORD FOUND:",
      "FOO=12345",
      "--END OF LIST--"
  }
  </code></pre>