Tag: lex

如何创建解析器(lex / yacc)?

我有以下文件,需要解析 –TestFile Start ASDF123 Name “John” Address “#6,US” end ASDF123 以–开头的行将被视为注释行。 并且文件以“开始”开始,以“结束” end 。 Start之后的字符串是UserID ,然后name和address将在双引号内。 我需要解析文件并将解析后的数据写入xml文件。 所以生成的文件就像 现在我使用模式匹配( Regular Expressions )来解析上面的文件。 这是我的示例代码。 /// /// To Store the row data from the file /// List MyList = new List(); String strName = “”; String strAddress = “”; String strInfo = “”; 方法 :ReadFile /// /// […]