public RobFile Read(string path) { using (var file = File.OpenRead(path)) { var parser = new Mcs3RobParser(); parser.Error += (sender, args) => Error?.Invoke(sender, args); parser.Parse(file); if (parser.AstFile == null) { return(null); } try { var astFile = parser.AstFile; var robFileHeader = ReadRobFileHeader(astFile.FileHeader); return(new RobFile() { FileHeader = robFileHeader, DeviceParams = ReadRobDeviceParams(astFile, robFileHeader.ControlUnitType), Constants = ReadRobConstants(astFile), Variables = ReadRobVariables(astFile), CharacteristicMaps = ReadCharacteristicMaps(astFile), RomTexts = ReadRomTexts(astFile), }); } catch (Exception e) { this.OnError(new ErrorEventArgs(new ErrorContext(5, e))); return(null); } } }
public string ParseAst(string path) { using (var file = File.OpenRead(path)) { var parser = new Mcs3RobParser(); parser.Error += (sender, args) => Error?.Invoke(sender, args); parser.Parse(file); return(parser.AstFile?.ToString()); } }