¿Cómo crear un analizador sintáctico (lex / yacc)?

Tengo el siguiente archivo y es necesario analizarlo

--TestFile
Start ASDF123
Name "John"
Address "#6,US" 
end ASDF123

Las líneas comienzan con-- se tratará como líneas de comentarios. y el archivo comienza 'Inicio' y termina conend. La cadena después deStart es elUserID y luego elname yaddress estará dentro de las comillas dobles.

Necesito analizar el archivo y escribir los datos analizados en un archivo xml.

Así que el archivo resultante será como

<ASDF123>
  <Name Value="John" />
  <Address Value="#6,US" />
</ASDF123>

ahora estoy usando coincidencia de patrones Regular Expressions) para analizar el archivo anterior. Aquí está mi código de muestra.

    /// <summary>
    /// To Store the row data from the file
    /// </summary>
    List<String> MyList = new List<String>();

    String strName = "";
    String strAddress = "";
    String strInfo = "";

Métod: ReadFile

    /// <summary>
    /// To read the file into a List
    /// </summary>
    private void ReadFile()
    {
        StreamReader Reader = new StreamReader(Application.StartupPath + "\\TestFile.txt");
        while (!Reader.EndOfStream)
        {
            MyList.Add(Reader.ReadLine());
        }
        Reader.Close();
    }

Métod: FormateRowData

    /// <summary>
    /// To remove comments 
    /// </summary>
    private void FormateRowData()
    {
        MyList = MyList.Where(X => X != "").Where(X => X.StartsWith("--")==false ).ToList();
    }

Métod: ParseData

    /// <summary>
    /// To Parse the data from the List
    /// </summary>
    private void ParseData()
    {
        Match l_mMatch;
        Regex RegData = new Regex("start[ \t\r\n]*(?<Data>[a-z0-9]*)", RegexOptions.IgnoreCase);
        Regex RegName = new Regex("name [ \t\r\n]*\"(?<Name>[a-z]*)\"", RegexOptions.IgnoreCase);
        Regex RegAddress = new Regex("address [ \t\r\n]*\"(?<Address>[a-z0-9 #,]*)\"", RegexOptions.IgnoreCase);
        for (int Index = 0; Index < MyList.Count; Index++)
        {
            l_mMatch = RegData.Match(MyList[Index]);
            if (l_mMatch.Success)
                strInfo = l_mMatch.Groups["Data"].Value;
            l_mMatch = RegName.Match(MyList[Index]);
            if (l_mMatch.Success)
                strName = l_mMatch.Groups["Name"].Value;
            l_mMatch = RegAddress.Match(MyList[Index]);
            if (l_mMatch.Success)
                strAddress = l_mMatch.Groups["Address"].Value;
        }
    }

Métod: WriteFile

    /// <summary>
    /// To write parsed information into file.
    /// </summary>
    private void WriteFile()
    {
        XDocument XD = new XDocument(
                           new XElement(strInfo,
                                         new XElement("Name",
                                             new XAttribute("Value", strName)),
                                         new XElement("Address",
                                             new XAttribute("Value", strAddress))));
        XD.Save(Application.StartupPath + "\\File.xml");
    }

He oído hablar de ParserGenerator

Por favor, ayúdame a escribir un analizador usando lex y yacc. La razón de esto es, mi analizador existente Pattern Matching) no es flexible, más aún no es la forma correcta (creo que sí).

Cómo hago uso de laParserGenerator(He leídoCode Project Sample One yCode Proyecto Muestra Dos pero aún no estoy familiarizado con esto). Sugiérame un generador de analizador que genere analizadores de C #.

Respuestas a la pregunta(2)

Su respuesta a la pregunta